Oracle Certified Associate
Practice Set 02

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

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

Questions from 43 to 56

Question 43.

Select the most appropriate answer.
Given:

package demoPackage;

import java.util.Scanner;

public class Demo {
   int side, area;

   Demo area(Demo object1) {
      object1 = new Demo();
      object1.side = this.side;
      object1.area = object1.side * object1.side;
      return object1;
   }

   public static void main(String[] args) {
      Demo obj = new Demo();

      try (Scanner s = new Scanner(System.in)) {
           System.out.print("Enter length of a side: ");
           obj.side = s.nextInt();
      }

     // insert code here.
     System.out.println("Area of a Square: " + obj.area);

  }
}


Output:
length of a side: 20
Area of a Square: 400

Which option should replace the comments to get the above output?

Option a: Demo a = obj.area();
Option b: var a = obj.area(obj);
Option c: obj = obj.area(obj);
Option d: var a = obj.area(); 


Option c: obj = obj.area(obj);

Question 44.

Select the most appropriate answer.
Which of the following is true?


Option a: The java command-line argument is an argument i.e. passed at the time of running the java program.
Option b: When a Java program is executed once, data can be passed any number of times using Command-line arguments.
Option c: Command-line arguments help in a way of outputting data to a program.
Option d: The command-line arguments are passes at the time of compiling of a Java program.


Option a: The java command-line argument is an argument i.e. passed at the time of running the java program.

Question 45.

Select all correct answers.
Which of the following are incorrect?


Option a: 13*13/4+4-3%2 gives 45
Option b: 13+13/4+4-3%2 gives 19
Option c: 13+13/4-4-3%2 gives –15
Option d: 13+13/4-4-3/2 gives 18


Option c: 13+13/4-4-3%2 gives –15
Option d: 13+13/4-4-3/2 gives 18

Question 46.

Select all correct answers.
Which of the following return false?


Option a:
boolean y = false;
if (y = true) // do some thing;
Option b:
int value1 = 1;
int value2 = 2;
if(!(value1 == value2)) // do some thing;
Option c:
int n = 9; if(n % 2 == 0) // do some thing;
Option d:
int n = -10; if(n > 0) // do some thing; 


Option c:
int n = 9; if(n % 2 == 0) // do some thing;
Option d:
int n = -10; if(n > 0) // do some thing;

Question 47.

Select all correct answers.
Assuming that country is set for each class, Which two are correct?
Given:

10. public class DayLightSavings{
11.    private String country, name;
12.      public getCountry() { return country; }
13.   }

and:
24. class Asia extends DayLightSavings{
25.    public String getCountry() { return super.country; }
26. }
27.
28. class Europe extends DayLightSavings{
29.    public String getCountry(String timeZone) {
30.       return super.getCountry();
31.     }
32. }


Option a: Asia returns correct values.
Option b: Generates compile time error on line 12.
Option c: An exception is thrown at runtime.
Option d: Asia and Europe both return correct values.
Option e: Compilation fails because of an error at line 25.
Option f: Compilation fails because of an error at line 30.


Option b: Europe returns correct values.
Option e: Compilation fails because of an error at line 25.

Question 48.

Select all correct answers.
Under which three circumstances will the code finally block is executed?
Given:

31. // some code here
32.   try {
33.      // some code here
34.   } catch (SomeException se) {
35.      // some code here
36.   } finally {
37.       // some code here
38.   }



Option a: The instance gets garbage collected.
Option b: The code on line 33 throws an exception.
Option c: The code on line 35 throws an exception.
Option d: The code on line 31 throws an exception.
Option e: The code on line 33 executes successfully.


Option b: The code on line 33 throws an exception.
Option c: The code on line 35 throws an exception.
Option e: The code on line 33 executes successfully. 

Question 49.

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

11. public static void main(String[] args) {
12.    Object obj =new String[] { "Amar", "Akbar", "Antony" };
13.    String[] someArray = (String[])obj;
14.    for (String i: someArray) System.out.print(i +" ");
15.  }


Option a: Amar Akbar Antony
Option b: Compilation fails because of an error in line 12.
Option c: Compilation fails because of an error in line 13.
Option d: Compilation fails because of an error in line 14.
Option e: A ClassCastException is thrown at runtime.


Option a: Amar Akbar Antony 

Question 50.

Select all correct answers.
Which of the following is incorrect with respect to Java class?


Option a: Class is a set of object which shares common characteristics/ behavior and common properties/ attributes.
Option b: Class is a real-world entity. It is just a template or blueprint or prototype from which objects are created.
Option c: Class occupy memory.
Option d: Class is a group of variables of different data types and a group of methods.


Option b: Class is a real-world entity. It is just a template or blueprint or prototype from which objects are created.
Option c: Class occupy memory.

Question 51.

Select the most appropriate answer.
Below code is an example of?

public class Employee {
    private String name;
    private String idNum;
    private int age;
    public int getAge() {
        return age;
    }
    public String getName() {
        return name;
    }
    public String getIdNum() {
        return idNum;
    }
    public void setAge( int newAge) {
        age = newAge;
    }
    public void setName(String newName) {
        name = newName;
    }
    public void setIdNum( String newId) {
        idNum = newId;
    }
}



Option a: Abstraction
Option b: Encapsulation
Option c: polymorphism
Option d: None of the above. 


Option b: Encapsulation 

Question 52.

Select the most appropriate answer.
Given:

1. public class Game implements Comparable<Game > {
2.    private int wins, losses;
3.    public Game(int w, int 1) { wins = w; losses = 1; }
4.    public int getWins() { return wins; }
5.     public int getLosses() { return losses; }
6.     public String toString() {
7.      return “<“ + wins + “,“ + losses + “>”;
8. }
9.   // insert code here
10. }


Which method will complete this class?

Option a: public int compareTo(Object o) {/*mode code here*/}
Option b: public int compareTo(Game other) {/*more code here*/}
Option c: public int compare(Game g1,Game g2){/*more code here*/}
Option d: public int compare(Object o1,Object o2){/*more code here*/}


Option b: public int compareTo(Game other) {/*more code here*/} 

Question 53.

Select the most appropriate answer.
Given:

1. public class Test {
2.    private String str;
3.    public Test (String name) { this.str= str; }
4.    public boolean equals(Test t) {
5.         return t.str.equals(this.str);
6.    }
7. }



Which is true?

Option a: The equals method does NOT properly override the Object.equals method.
Option b: Compilation fails because the private attribute t.str cannot be accessed in line 5.
Option c: To work correctly with hash-based data structures, this class must also implement the hashCode method.
Option d: When adding Test objects to a java.util.Set collection, the equals method in line 4 will prevent duplicates. 



Option a: The equals method does NOT properly override the Object.equals method. 

Question 54.

Select all correct answers.
Which of the following are Assignment operators?


Option a: =
Option b: <=
Option c: !=
Option d: +=


Option a: =
Option d: +=

Question 55.

Select all correct answers.
Given:

11. public class Commander {
12.    public static void main(String[] args) {
13.       String myProp = /* insert code here */
14.       System.out.println(myProp);
15.    }
16. }


and the command line: java -Dprop.custom=HelloWorld Commander
Which two, placed on line 13, will produce the output HelloWorld?

Option a: System.load(”prop.custom”);
Option b: System.getenv(”prop.custom”);
Option c: System.property(”prop.custom”);
Option d: System.getProperty(”prop.custom”);
Option e: System.getProperties().getProperty(”prop.custom”);


Option d: System.getProperty(”prop.custom”);
Option e: System.getProperties().getProperty(”prop.custom”); 

Question 56.

Select all correct answers.
Which of the following are true?


Option a: Encapsulation doesn’t hide implementation behind an interface (or API).
Option b: IS-A refers to inheritance or implementation.
Option c: IS-A is expressed with the keyword extends or implements.
Option d: IS-A, “inherits from,” and “is a subtype of” are not equivalent expressions.
Option e: HAS-A means an instance of one class “has a” reference to an instance of another class or another instance of the same class.


Option b: IS-A refers to inheritance or implementation.
Option c: IS-A is expressed with the keyword extends or implements.
Option e: HAS-A means an instance of one class “has a” reference to an instance of another class or another instance of the same class.

 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.

Mobirise Website Builder
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 ‌

Drag and Drop Website Builder