Oracle Java SE 8 Certification - OCAJP 1Z0-808 Practice Tests Set 43

Which of these class names best follows standard Java naming conventions?


Options are :

  • tipCalculator
  • TipCalculator (Correct)
  • Tip_Calculator
  • tip-calculator

Answer :TipCalculator

Oracle Java SE 8 Certification - OCAJP 1Z0-808 Practice Tests Set 28

How many objects are eligible for garbage collection at the end of the main() method?


Options are :

  • None
  • One (Correct)
  • Two
  • Three
  • The code does not compile.

Answer :One

Which of the following is not a valid order for elements in a class?


Options are :

  • Instance variables, method, constructor
  • Constructor, instance variables, method
  • Method, instance variables, constructor
  • None of the above. All three orders is valid (Correct)

Answer :None of the above. All three orders is valid

What is the output for this code?


Options are :

  • 2
  • 0
  • 1
  • There is a syntax error (Correct)

Answer :There is a syntax error

Oracle Java SE 8 Certification - OCAJP 1Z0-808 Practice Tests Set 15

Select the correct statements from the following options. 


Options are :

  • To encapsulate means to make some instance variables and methods inaccessible permanently from program
  • To encapsulate means to make some instance variables and methods inaccessible from outside a class (Correct)
  • While encapsulating, we usually make all instance variables private, and most instance methods public (Correct)
  • While encapsulating, we usually make all instance variables public, and most instance methods private

Answer :To encapsulate means to make some instance variables and methods inaccessible from outside a class While encapsulating, we usually make all instance variables private, and most instance methods public

Which variable is always available to all instances of the class?


Options are :

  • local
  • instance
  • static except private (Correct)
  • public

Answer :static except private

Which statements are true about a Constructor in Java?


Options are :

  • It can be created with different name as the class
  • A Constructor is a special method that has no return type (Correct)
  • Instance variables can not be initialized in the Constructor
  • It is called once and once only, when the object is created (Correct)

Answer :A Constructor is a special method that has no return type It is called once and once only, when the object is created

Oracle Java SE 8 Certification - OCAJP 1Z0-808 Practice Tests Set 45

What is the output of this class?


Options are :

  • Total: 6.0 (Correct)
  • Total: 4.0
  • Total: 5.0
  • Total: 8.0

Answer :Total: 6.0

Which statement about a no-argument constructor is true?


Options are :

  • If a class extends another class that has only one constructor that takes a value, then the child class must explicitly declare at least one constructor (Correct)
  • The Java compiler will always insert a default no-argument constructor if you do not define a no-argument constructor in your class.
  • A class may contain more than one no-argument constructor
  • No one is true

Answer :If a class extends another class that has only one constructor that takes a value, then the child class must explicitly declare at least one constructor

How many syntax error the switch statement has?


Options are :

  • Code has no error
  • 3
  • 1 (Correct)
  • 2

Answer :1

Oracle Java SE 8 Certification - OCAJP 1Z0-808 Practice Tests Set 23

Which of the following is not a reason to use encapsulation when designing a class?


Options are :

  • Prevent users from modifying the internal attributes of a class.
  • Increase concurrency and improve performance. (Correct)
  • Promote usability by other developers
  • Maintain class data integrity of data elements.

Answer :Increase concurrency and improve performance.

How many final modifiers would need to be removed to compile this application?


Options are :

  • Two (Correct)
  • Three
  • One
  • Four

Answer :Two

What does the following code output?


Options are :

  • 1
  • 0 (Correct)
  • 2
  • 3

Answer :0

Oracle Java SE 8 Certification - OCAJP 1Z0-808 Practice Tests Set 16

What is the output of the following code?


Options are :

  • 0
  • man
  • False
  • True (Correct)

Answer :True

Which of the following loop body can be used in "line 3" to compile the given main method? (Select two)


Options are :

  • while ((m = 0) !=5) { } (Correct)
  • while (m) { }
  • while(m > n) { } (Correct)
  • while (n) { }
  • while (m && n) { }

Answer :while ((m = 0) !=5) { } while(m > n) { }

Which of the following statements is correct? 


Options are :

  • There may be any number of copies of an instance variable: one for each instance of the class (Correct)
  • There is exactly one copy of an instance variable among all the instances of the class
  • Instance variables are never primitive type
  • None of the above

Answer :There may be any number of copies of an instance variable: one for each instance of the class

Oracle Java SE 8 Certification - OCAJP 1Z0-808 Practice Tests Set 10

Which of the following is an overloading method? 


Options are :

  • Public class A { public void foo(int a) { } } Public class B extends A {public void foo(int a) { } }
  • Public class A { public void foo(int a) { } public void foo(int a, int b) { } } (Correct)
  • Public class A { public void foo(int a) { } public void Foo(int a, int b) { } }
  • None of the above

Answer :Public class A { public void foo(int a) { } public void foo(int a, int b) { } }

How many lines of the following application do not compile?


Options are :

  • None. The code compiles and prints swim!
  • None. The code compiles and prints a stack trace.
  • One (Correct)
  • Two
  • Three

Answer :One

How many times does the following code print true?


Options are :

  • One
  • Two
  • Three (Correct)
  • Four
  • Five
  • None. The code does not compile.

Answer :Three

Oracle Java SE 8 Certification - OCAJP 1Z0-808 Practice Tests Set 22

Which of the following statements about inheritance is true?



Options are :

  • Multiple inheritance is not permitted in Java
  • Multiple inheritance is permitted for any classes
  • Multiple inheritance is permitted by using interfaces (Correct)
  • None of the above

Answer :Multiple inheritance is permitted by using interfaces

Let the passengers array that contains person's name, and setName() is a method to set a name. what is an enhanced for loop to set the name of every
Passenger object in the array to "Sally"?


Options are :

  • for (Passenger p: passengers) { p.setName("Sally"); } (Correct)
  • for (Passenger p: passengers) { setName("Sally"); }
  • for (Passenger p: passengers) { p.equals.setName("Sally"); }
  • None of the above

Answer :for (Passenger p: passengers) { p.setName("Sally"); }

What is a possible output of the following code?


Options are :

  • Code has compilation error
  • [null null null]
  • [0 0 0]
  • A reference address (Correct)

Answer :A reference address

Oracle Java SE 8 Certification - OCAJP 1Z0-808 Practice Tests Set 36

Which of the following statements is incorrect about interface?


Options are :

  • A class can implement two interfaces
  • An interface can extend another interface
  • An interface can implement another interface (Correct)
  • A class can extend another class

Answer :An interface can implement another interface

Which one of the following is correct code for printing numbers from 1 to 10 in single line.


Options are :

  • for(int x = 1; x <= 10; x++) { System.out.println(x); }
  • for(x = 1; x <=10; x++) { System.out.print(x); }
  • for(int x = 1; x <= 10; x++) { System.out.print(x); } (Correct)
  • for(int x = 1; x <= 10; ++x) { System.out.println(x); }

Answer :for(int x = 1; x <= 10; x++) { System.out.print(x); }

Which of the following are legal declarations? (select two)


Options are :

  • [][] String alif;
  • String[] ba[]; (Correct)
  • [] String ba;
  • String ta[][]; (Correct)
  • []String sa[][];

Answer :String[] ba[]; String ta[][];

Oracle Java SE 8 Certification - OCAJP 1Z0-808 Practice Tests Set 49

Fill in the blank: Both overloaded and overridden methods have _________.


Options are :

  • same return type
  • same signature in the method
  • different method name
  • same method name (Correct)

Answer :same method name

Which of the following exception types must be handled or declared by the method in
which they are thrown?


Options are :

  • ArithmeticException
  • RuntimeException
  • Exception (Correct)
  • NullPointerException

Answer :Exception

What is the output of this code?


Options are :

  • A living thing.
  • A Bird. An animal.
  • A Bird.
  • A Bird. An animal. A living thing. (Correct)

Answer :A Bird. An animal. A living thing.

Oracle Java SE 8 Certification - OCAJP 1Z0-808 Practice Tests Set 25

Which is the first line to prevent this code from compiling and running?


Options are :

  • line 1
  • line 2 (Correct)
  • line 3
  • line 4

Answer :line 2

In Java Object Oriented Programming, which one is correct? (Select two)


Options are :

  • Parameters and local variables need not be declared using types
  • Main method is not needed to execute the program
  • Return values send back information from the object (Correct)
  • Methods implement a specific behavior of an object. (Correct)

Answer :Return values send back information from the object Methods implement a specific behavior of an object.

Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions