Oracle Certified Associate
Practice Set 01

Java SE 8 Programmer I exam (1Z0 | 808) Certification

Duration 120 minutes,
Format: Multiple Choice
Number of Questions: 56
Passing Score: 65%

Questions from 15 to 28

Question 15.

Select the most appropriate answer.
Given two files:
What is the output?

// File 1

01. package pkgA;
02. public class Go {
03.    public a = 8;
04.    public int b = 4;
05     public int c = 5;
06. }

// File 2

12. package pkgB;
13. import pkgA.*;
14. public class Demo{
15.     public static void main(String[] args) {
16.           Go g = new Go();
17.            System.out.print(" " + g.a + g.b);
18.            System.out.print(" " + g.b + g.c);
19.            System.out.println(" " + g.c + g.a);
20.     }
21. }



Option a:
 84 45 58
Option b: 84 followed by an exception
Option c: Compilation fails with an error on line 17
Option d: Compilation fails with an error on line 18
Option e: Compilation fails with an error on line 19
Option f: Compilation fails with an error on line 16


Option a: 56 67 75 

Question 16.

Type your answer.
Using the fragments below, complete the following code so it compiles. Note, you may not have to fill all of the slot.
Code:

class AgedP {
     __________
     __________
     public AgedP(int x) { }
}
public class Kinder extends AgedP {
     public Kinder(int x) {
           super();
     }
}


Fragments: Use the following fragments zero or more times:
     AgedP
     super
     this
     (
      )
     {
      }
      ;


AgedP() {}

Question 17.

Select the most appropriate answer.
Given:

11. public static void stringTest(String str) {
12.    if(str == null | str.length() == 0) {
13.      System.out.println(”String is empty”);
14.    } else {
15.      System.out.println(”String is not empty”);
16.    }
17. }


And the invocation: 31. stringTest("Hello");
What is the result?

Option a: An exception is thrown at runtime.
Option b: “String is empty” is printed to output.
Option c: Compilation fails because of an error in line 12.
Option d: “String is not empty” is printed to output. 


Option d: “String is not empty” is printed to output. 

Question 18.

Select the most appropriate answer.
Given:

11.        class Snoochy {
12.           Boochy booch;
13.           public Snoochy() { booch = new Boochy(this); }
14.       }
15.
16.       class Boochy {
17.           Snoochy snooch;
18.           public Boochy(Snoochy s) { snooch = s; }
19.       }
And the statements:
21.      public static void main(String[] args) {
22.             Snoochy snoog = new Snoochy();
23.             snoog = null;
24.             // more code here
25.       }


Which statement is true about the objects referenced by snoog, snooch, and booch immediately after line 23 executes?

Option a: None of these objects are eligible for garbage collection.
Option b: Only the object referenced by booch is eligible for garbage collection.
Option c: Only the object referenced by snoog is eligible for garbage collection.
Option d: Only the object referenced by snooch is eligible for garbage collection.
Option e: The objects referenced by snooch and booch are eligible for garbage collection.


Option e: The objects referenced by snooch and booch are eligible for garbage collection.

Question 19.

Select the most appropriate answer.
Given:

11. ho = new HugeObject();
12.    // more code here
13. ho = null;
14.    /* insert code here */


Which statement should be placed at line 14 to suggest that the virtual machine expend effort toward recycling the memory used by the object ho?

Option a: System.gc();
Option b: Runtime.gc();
Option c: System.freeMemory();
Option d: Runtime.getRuntime().growHeap();
Option e: Runtime.getRuntime().freeMemory();


Option a: System.gc();

Question 20.

Select the most appropriate answer.
Given the following code what is the effect of :

1. package demoPackage;
2. class Test {
3.
4.    public int add(int a) {
5.          loop: for (int i = 1; i < 3; i++){
6.             for (int j = 1; j < 3; j++) {
7.                if (a == 5) {
8.                   break loop;
9.             }   else {
10.                    a = a + a;
11.                }
12.           }
13.       }
14.       return a;
15.    }
16.    public String printDetails(int a) {
17.       a = a/0;
18.       String str = "Sum is = " + a;
19.       return str;
20.     }
21.
22.   }
23.
24. public class Demo {
25.     public static void main (String args []) {
26.         Test a = new Test();
27.          int num = a.add(2);
28.          System.out.println(a.printDetails(num));
29.      }
30.  }


Option a: Generate a runtime error
Option b: Throw an ArrayIndexOutOfBoundsException
Option c: Prints: Sum is = 32
Option d: Produces no output


Option a: Generate a runtime error

Question 21.

Select the most appropriate answer.
What is the effect of issuing a wait() method on an object


Option a: If a notify() method has already been sent to that object then it has no effect
Option b: The object issuing the call to wait() will be automatically synchronized with any other objects using the receiving object.
Option c: An exception will be raised
Option d: None of the above.


Option d: None of the above.

Question 22.

Select all correct answers.
The layout of a container can be altered using which of the following methods:


Option a: setLayoutManager(aLayoutManager);
Option b: addLayout(aLayoutManager);
Option c: layout(aLayoutManager);
Option d: None of the above.


Option d: None of the above.

Question 23.

Select all correct answers.
Which of the following are not Java keywords?


Option a: goto
Option b: malloc
Option c: extends
Option d: FALSE
Option e: else


Option b: malloc 
Option d: FALSE

Question 24.

Select the most appropriate answer.
What will be the result of compiling the following code:

public class Demo {
   public static void main (String args []) {
       String firstName;
       String lastName;
       String fullName = firstName + " " + lastName;
       System.out.println(“Name is “ + fullName );
   }
}


Option a: Compiles and runs with no output
Option b: Compiles and runs printing out fullName.
Option c: Compiles but generates a runtime error
Option d: Does not compile
Option e: Compiles but generates a compile time error 


Option d: Does not compile. The local variables firstName and lastName not initialized.

Question 25.

Select the most appropriate answer.
Which of these is the correct format to use to create the literal char value a?


Option a: \000a
Option b: “a”
Option c: new Character(a)
Option d: None of the above.


Option d: None of the above.

Question 26.

Select the most appropriate answer.
What is the result?
Given:

1. public class Computer implements Software
2.     { public void doIt() { } }
3.         abstract class Laptop1 implements Computer { }
4.         abstract class Laptop2 implements Computer
5.     { public void doIt(int x) { } }
6. class Laptop3 extends Computer implements Software
7.         { public void doStuff() { } }
8.        interface Software { public void doIt(); }


Option a: Compilation succeeds
Option b: Compilation fails with multiple errors
Option c: Generates run-time error
Option d: None of the above.



Option b: Compilation fails with multiple errors

Question 27.

Select the most appropriate answer.
Which statement(s) are true?


Option a: Cohesion is the Object Oriented principle most closely associated with hiding implementation details
Option b: Cohesion is the Object Oriented principle most closely associated with making sure that classes know about other classes only through their APIs
Option c:  Cohesion is the Object Oriented principle most closely associated with allowing a single object to be seen as having many types
Option d: None of the above.


Option d: None of the above.

Question 28.

Select the most appropriate answer.
Given:

import java.util.*;
   public class Mixup {
      public static void main(String[] args) {
            Object o = new Object();
                // insert code here
               s.add("o");
               s.add(o);
        }
   }



And these three fragments:
Fragment I: Set s = new HashSet();
Fragment II: TreeSet s = new TreeSet();
Fragment III: LinkedHashSet s = new LinkedHashSet();

When fragments I, II, or III are inserted, independently, at line 7, which of the following is incorrect?

Option a: Fragment I compiles
Option b: Fragment II compiles
Option c: Fragment III compiles
Option d: Fragment I executes without exception
Option e: Fragment II executes without exception
Option f: Fragment III executes without exception


Option e: Fragment II executes without exception 

 OCA Practice Tests (1Z0-808) app contributes in achieving Oracle Certified Associate (OCA) certification.

A total of 10 premium tests are provided.

The purpose of these practice tests is to assist Oracle Certified Associate (OCA) Aspirants to manage time better in the actual exam by asking them to answer questions similar to the ones that appear in exams. The test series helps you assess your preparation and identify your weakness well before the exam, thus assisting you prepare better.

Tests also include features like:
• 60 minutes, 15 minutes and 5 minutes remaining voice alerts.
• After completion, your performance is assessed and a report is generated.
• App also provides correct answers for the test after completion.

OCA Mobile Application
https://play.google.com/store/apps/details?id=in.co.vtree.ocamobiletab

Contact Details :---             
WhatsApp Number: +91 97422 63639              Telegram Number:  +91 97422 63639    
Mobile Number: +91 97422 63639              email id: contact@drdhajnana.com
Privacy Policy       Terms of Service
vtree.co.in

Made with ‌

HTML Editor