1 / 26

JAVA Revision Lecture

JAVA Revision Lecture. Electronic Voting System Marina De Vos. 0a. What are the languages used in this unit?. C and Java Python and Java Perl and VisualBasic. 0b. Ada Lovelace was the first …. female programmer the wife of the first programmer programmer.

aleron
Download Presentation

JAVA Revision Lecture

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. JAVA Revision Lecture Electronic Voting System Marina De Vos

  2. 0a. What are the languages used in this unit? • C and Java • Python and Java • Perl and VisualBasic

  3. 0b. Ada Lovelace was the first … • female programmer • the wife of the first programmer • programmer

  4. 1. Which one of the sentences is true considering the following lines of code: • the class Town contains a constructor with a String as a parameter • bath is an instance of the class England • bath is an object of type String String country = "England";Town bath = new Town(country);

  5. 2. What is the value returned while calling the method refundBalance(10)? • 0 • 10 • 100 • Same value as before public int refundBalance(int nb){ balance=100; return balance; balance=0; }

  6. 3. Which one of the following sentences is correct? • Fields represent local variables of a method • The scope of a local variable is linked to its defining method • Fields are defined inside constructors • Local variables are defined in the header of a method • A private field can be accessed from outside their defining class

  7. 4. Which values have the variables a and b after the execution of the following lines of code: • a=3; b=4; • a=4; b=4; • a=3; b=5; • a=5; b=4; • a=4; b=5; int a=3; int b=5; int c=a++; int d=--b; if ((a+1)==d){ c++; b--; } if (c!=b){ a++; } else { b++; }

  8. 5. What is the result of n? boolean pass=false; int n=0; for (int i=0; i<10; i++) { n+=i; if (pass) { i+=2; } pass = !pass; } • 27 • 25 • 45

  9. 6. Why do you need to add 'throws' to a method signature... • To Specify the exceptions thrown by a method • To specify the exceptions caught by a method • To Specify that a method overrides an exception • Both 1 and 2 are correct Choice One

  10. 7. A 'try' must be followed by one or more 'catch' blocks. • True • False

  11. 8. What happens to the object being created when an exception is thrown from a constructor? • null is returned and the partial object is garbage collected • a partial object is created • null is returned • the object is fully created

  12. 9. Code that is well designed is: • tighly coupled and not cohesive • loosly coupled and not cohesive • tighly coupled and highly cohesive • loosly coupled and highly cohesive

  13. 10. Java is a … • weakly and statically typed language • weakly and dynamically typed language • strongly and statically typed language • strongly and dynamically typed language

  14. 11. The lifetime and scope of a variable a is defined by the enclosing {} braces. • True • False

  15. 12. Object diagrams can present both a static and dynamic view of a program. • True • False

  16. 13. To create a new primitive type in Java, you can... • copy an existing primitive type definition and edit • ...you can't! • use the new primitive keyword • not necessary - all new types are primitive types

  17. 14. A & B is the same as B & A for any boolean expression in Java. • True • False

  18. 15. In Java, it is not possible to have more than one method with the same name. • True • False

  19. 16. Consider the following code snippet: What will the output be? • arr • Nothing, it will generate an error. • arr matey • matey HashMap<String,String> map = new HashMap<String,String>(); map.put("key1","arr"); map.put("key1","matey"); System.out.println(map.get("key1"));

  20. 17. Which of the following statements is incorrect? • the static type of a variable is either the same as the dynamic type or a superclass • polymorphic method calls use the dynamic type • The compiler checks the static and dynamic type of a variable • an object reference can always be type cast back to its dynamic type

  21. 18 Newly declared methods can hide, implement, or override methods declared in a superclass or superinterface. • True • False

  22. 19 It is possible to have a variable with a static type corresponding to an abstract class • True • False

  23. 20 To simulate multiple inheritance you use: • nested classes • abstract classes • interfaces • inherited classes

  24. EVS is good fun, something different and its very good to be interactive Since we do not get much class participation, except if we want to ask questions • Strongly Agree • Agree • Neutral • Disagree • Strongly Disagree

  25. Java EVS vs Python Quiz • evs • Quiz • I liked both • I liked neither

  26. EVS: Although good for general feed-back how we are doing, it’s not so good for passing course material on. • Strongly Agree • Agree • Neutral • Disagree • Strongly Disagree

More Related