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 29 to 42

Question 29.

Select all correct answers.
For the given code, which of the following can be the resulting console output?
Given:

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Demo {
   static int total = 10;
   public static void main (String args []) throws IOException{
      BufferedReader bfn = new BufferedReader(new InputStreamReader(System.in));
      System.out.println("Enter your Name.");
      String str = bfn.readLine();
      System.out.println("Hello Mr. " + str + ".");
   }


Option a: Enter your Name.
Roy
Hello Mr. Roy.
Option b: Enter your Name.
Raj
Hello Mr. X.
Option c: Enter your Name.
Prince
Hello Mr. Prince.
Option d: Enter your Name.
Max
Hello Mr. Mad.
Option e: Enter your Name.
Joe
Hello Mr. J. 


Option a: Enter your Name.
Roy
Hello Mr. Roy.
Option c: Enter your Name.
Prince
Hello Mr. Prince.

Question 30.

Select the most appropriate answer.
What is the syntax for the switch statement in Java?


Option a: switch(expression) { case value: statement; break; }
Option b: switch(value) { case condition: statement; break; }
Option c: switch(value) { case value: statement; break; }
Option d: switch(condition) { case condition: statement; break; }


Option a: switch(expression) { case value: statement; break; } 

Question 31.

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

public class Main {
   public static void main(String[] args) {
      int num = 9;
      while(num > 3) {
          num--;
          System.out.print(num);
      }
   }
}


Option a: 65432
Option b: 876543
Option c: 5432
Option d: 76543
Option e: 654321
Option f: 7654321


Option b: 876543 

Question 32.

Select the most appropriate answer.
What is the output of the following code snippet?

public class Main {
   public static void main(String[] args) {
      char num1 = 'a';
      char num2 = 'b';
       double result = num2 % num1;
       System.out.println(result);
   }
}


Option a: 0.0
Option b: 1.0
Option c: 2.0
Option d: The code does not compile.
Option e: An exception is thrown at runtime. 


Option b: 1.0 

Question 33.

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


Option a: You can have any number else for a given if.
Option b: You can have zero to many else ifs for a given if, and they must come before the (optional) else.
Option c: Once an else if succeeds, none of the remaining else ifs nor the else will be tested.
Option d: In Java if-else statements is used to execute a set of statements based on a specific condition, if the condition is not met execute another set of statements based on some other condition, and yet another set of statements if these conditions are not met.


Option b: You can have zero to many else ifs for a given if, and they must come before the (optional) else.
Option c: Once an else if succeeds, none of the remaining else ifs nor the else will be tested.

Question 34.

Select the most appropriate answer.
Given that f refers to an object that implements Predicate, which of the following cannot be valid code snippets or statements?



Option a: if(f.test(m))
Option b: switch (f.test(m))
Option c: while(f.test(m))
Option d: f.test(m) ? "yes" : "no";
Option e: do {} while(f.test(m));
Option f: System.out.print(f.test(m));
Option g: boolean b = f.test(m);


Option b: switch (f.test(m)) 

Question 35.

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


Option a: Every constructor has, as its first statement, either a call to an overloaded constructor (this()) or a call to the superclass constructor (super()), although this call can be inserted by the compiler.
Option b: Abstract classes will never have constructors.
Option c: Interfaces have constructors and those constructors are always called when a concrete class is instantiated.
Option d: The default constructor is NEVER a no-arg constructor.


Option b: Abstract classes will never have constructors.
Option c: Interfaces have constructors and those constructors are always called when a concrete class is instantiated.
Option d: The default constructor is NEVER a no-arg constructor.

Question 36.

Type correct answers.
Type the Code Fragments that can be inserted at line 08 to print the given output?

01. class Language {
02.    public void displayInfo() {
03.       System.out.println("Common English Language");
04.    }
05. }
06. class Japanese extends Language {
07. public void displayInfo() {
08.   //Insert the code here.
09.    System.out.println("Japanese is a popular language");
10.    }
11. }
12. class Main {
13.    public static void main(String[] args) {
14.       Japanese j1 = new Japanese();
15.       j1.displayInfo();
16.    }
17. }


Output:
Common English Language
Japanese is a popular language

Code Fragments:
super
displayInfo
(
)
;
.


  super.displayInfo(); 

Question 37.

Select the most appropriate answer.
Fill in the blanks: If your application is, it must first have been with respect to supporting multiple languages.


Option a: extracted, internationalized
Option b: extracted, localized
Option c: internationalized, extracted
Option d: internationalized, localized
Option e: localized, extracted
Option f: localized, internationalized


Option f: localized, internationalized

Question 38.

Select the most appropriate answer.
What is the result of the following program?

1. public class Main {
2.    public static void main(String[] args) {
3.       int num1 = 9;
4.       int num2 = 8;
5.        int num3 = 5;
6.        int num4 = 5;
7.        int num5 = 3;
8.        int result = num5 * num4 - (num1 + num2) / num3 ;
9.        System.out.print(result);
10.    }
11.  }


Option a: 9
Option b: 11
Option c: 12
Option d: Compiler error on line 2.
Option e: Compiler error on line 8.
Option f: Runtime error on line 8.


Option c: 12

Question 39.

Select all correct answers.
Which of the following are incorrect with respect to the method it overrides, the overriding method?


Option a: May throw fewer or narrower checked exceptions, or any unchecked exception
Option b: Must throw new or broader checked exceptions
Option c: Must not have a more restrictive access modifier.
Option d: Must not have the same argument list.
Option e: May have a less restrictive access modifier


Option b: Must throw new or broader checked exceptions
Option d: Must not have the same argument list.

Question 40.

Select the most appropriate answer.
Which of the following is a recommended way to define an asynchronous task?



Option a:
Create a Callable expression and pass it to an instance of Executors.
Option b: Create a class that extends Thread and overrides the start() method.
Option c: Create a Runnable expression and pass it to a Thread constructor.
Option d: All of the above


Option a: Create a Callable expression and pass it to an instance of Executors.

Question 41.

Select all correct answers.
Which of these options are examples of method overloading?


Option a:
int func98() { ... }
int func98(int a) { ... }
String func98(double a) { ... }
double func98(int a, float b) { ... }
Option b:
void func1() { ... }
void func2(int a) { ... }
float func3(double a) { ... }
float func4(int a, float b) { ... }
Option c:
void func4() { ... }
void func_4(int a) { ... }
float func04(double a) { ... }
float func40(int a, float b) { ... }
Option d:
void func2() { ... }
void _func2(int a) { ... }
float func_2(double a) { ... }
float _func02(int a, float b) { ... }
Option e:
void func() { ... }
void func(int a) { ... }
float func(double a) { ... }
float func(int a, float b) { ... } 


Option a:
int func98() { ... }
int func98(int a) { ... }
String func98(double a) { ... }
double func98(int a, float b) { ... }
Option e:
void func() { ... }
void func(int a) { ... }
float func(double a) { ... }
float func(int a, float b) { ... } 

Question 42.

Select the most appropriate answer.
Which interface name inserted into the blank below allows the code snippet to compile?

Path file = Paths.get("/data/movie.txt");
BasicFileAttributes b = Files.readAttributes(file, );


Option a: BasicFileAttributes.class
Option b: DosFileAttributes.class
Option c: PosixFileAttributes.class
Option d: All of the above 


Option d: All of the above

 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

Built with ‌

Mobirise.com