Java SE 8 Programmer I exam (1Z0 | 808) Certification
Duration 120 minutes,
Format: Multiple Choice
Number of Questions: 56
Passing Score: 65%
Questions from 01 to 14
Select the most appropriate answer.
What is the result for the given code?
package demoPackage;
class Top {
public Top(String s) {
System.out.print(s);
}
}
public class Demo extends Top {
public Demo(String s) {
super(s);
System.out.print(" ");
System.out.print(s);
}
public static void main(String[] args) {
new Demo("X");
System.out.print(" ");
System.out.print("X");
}
}
Option a: X
Option b: X X
Option c: X X X
Option d: Generates runtime error
Option e: Compilation fails
Option c: X X X
Type correct answers.
Given:
public class Oop {
public static void main(String [] args) {
//insert code here.
}
static void doSomething(int javaVersion) {
System.out.println("Java " + javaVersion);
}
}
When compiled to give the output,
Java 8
Type the code fragment to replace the comment.
doSomething(8);
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(null);
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 a: An exception is thrown at runtime.
Select the most appropriate answer.
A UNIX user named Bob wants to replace his chess program with a new one, but he is hot sure where the old one is installed. Bob is currently able to run a Java chess program starting from his home directory /home/bob using the command:
java -classpath /test:/home/bob/downloads/* .jar games.Chess
Bob’s CLASSPATH is set (at login time) to:
/usr/lib:/home/bob/classes:/opt/java/lib:/opt/java/lib/* .jar
What is a possible location for the Chess.class file?
Option a: /test/Chess.class
Option b: /home/bob/Chess.class
Option c: /test/games/Chess.class
Option d: /usr/lib/games/Chess.class
Option e: /home/bob/games/Chess.class
Option f: inside jarfile /opt/java/lib/Games.jar (with a correct manifest)
Option g: inside jarfile /home/bob/downloads/Games.jar (with a correct manifest)
Option c: /test/games/Chess.class
Select all correct answers.
Given:
1. package com.company.application;
2.
3. public class DemoClass {
4. public static void main(String[] args) { }
5. }
And DemoClass exists in the /apps/com/company/application directory. Assume the CLASSPATH environment variable is set to “.“ (current directory). Which two java commands entered at the command line will run DemoClass?
Option a: java DemoClass if run from the /apps directory
Option b: java com.company.application.DemoClass if run from the /apps directory
Option c: java -classpath /apps com.company.application.DemoClass if run from any directory
Option d: java -classpath.DemoClass if run from the /apps/com/company/application directory
Option e: java -classpath/apps/com/company/application:.DemoClass if run from the /apps directory
Option f: java com.company.application.DemoClass if run from the /apps/com/company/application directory
Option b: java com.company.application.DemoClass if run from the /apps directory
Option c: java -classpath /apps com.company.application.DemoClass if run from any directory
Select the most appropriate answer.
In the following code, which is the earliest statement, where the object originally held in e, may be garbage collected:
1. public class demo {
2. public static void main (String args []) {
3. Employee e = new Employee("Bob", 48);
4. e.calculatePay();
5. System.out.println(e.printDetails());
6. e = null;
7. e = new Employee("Denise", 36);
7. e.calculatePay();
9. System.out.println(e.printDetails());
10. }
11. }
Option a: Line 10
Option b: Line 11
Option c: Line 7
Option d: Line 8
Option e: Never
Option c: Line 7
Type correct answers.
Given:
1: public class Demo {
2: public static void main(String[] args) {
3: int x = 5, j = 0;
4: OUTERLOOP: for(int i=0; i<3; )
5: INNERLOOP: do {
6: i++; x++;
7: if(x > 10) break INNERLOOP;
8: x += 4;
9: j++;
10: } while(j <= 2);
11: System.out.println(x);
12: } }
Type the output.
12
Select the most appropriate answer.
What is the result of the following program?
1: public class CustomColor {
2: static String color1;
3: private String color2;
4: public Demo() {
5: color1 = "white";
6: }
7: public Demo(String color) {
8: if (color == "white") color2 = "black";
9: else color2 = color;
10: }
11: public static void main(String[] args) {
12: Demo e = new Demo();
13: System.out.print("Color 1: " + color1 +";");
14: Demo e2 = new Demo(color1);
15: System.out.print(" Color 2: " + e2.color2 +";");
16: }
17: }
Option a: Color 1: ; Color 2: ;
Option b: Color 1: white; Color 2: black;
Option c: Color 1: null; Color 2: null;
Option d: Compiler error on line 4.
Option e: Compiler error on line 7.
Option f: Compiler error on line 14.
Option b: Color 1: white; Color 2: black
Select the most appropriate answer.
Given:
5. int []x= {110, 120, 130, 140, 150 };
6. int y[] =x;
7. System.out.println(y[3]);
Which is true?
Option a: Line 7 will print the value 120.
Option b: Line 7 will print the value 140.
Option c: Compilation will fail because of an error in line 5.
Option d: Compilation will fail because of an error in line 6.
Option b: Line 7 will print the value 140.
Select the most appropriate answer.
Output:
Mr. X.
What should be inserted in line 7 to get the above output?
01. public class Demo {
02. public static void main (String args []){
03. String output = append("Mr.");
04. System.out.print(output);
05. }
06. static String append(String str) {
07. // insert the code here.
08. return str;
09. }
10. }
Option a: str =" X";
Option b: str = str +" X";
Option c: str == " X";
Option d: str += str+" X";
Option b: str = str + " X";
Select the most appropriate answer.
A programmer is designing a class to encapsulate the information about an inventory item. A JavaBeans component is needed to do this. The Inventoryltem class has private instance variables to store the item information:
10. private int itemId;
11. private String name;
12. private String description;
Which method signature follows the JavaBeans naming standards for modifying the itemld instance variable?
Option a: itemID(int itemId)
Option b: update(int itemId)
Option c: setItemId(int itemId)
Option d: mutateItemId(int itemId)
Option e: updateItemID(int itemId)
Option c: setItemId(int itemId)
Select the most appropriate answer.
Given:
class First {
{ System.out.println("1"); }
public void Top() { System.out.println("2"); }
public void Top(String s) { System.out.println("3"); }
}
class Second extends First {
{ System.out.println("4"); }
public Second() { System.out.println("5"); }
public Second(String s) { System.out.println("6"); }
}
public class Third extends Second {
{ System.out.println("7"); }
public void Bottom()
{ System.out.println("8"); }
public void Bottom(String s) { System.out.println("9"); }
public static void main(String[] args) { new Third(); }
}
Option a: 147
Option b: 1457
Option c: 145
Option d: 23569
Option e: 123456
Option b: 1457
Select the most appropriate answer.
Given:
10. class One {
11. void foo() {}
12. }
13. class Two extends One {
14. //insert method here
15. }
Select the code fragment, inserted individually at line 14, will correctly complete class Two?
Option a: int foo() { /* more code here */ }
Option b: void foo() { /* more code here */ }
Option c: public String foo() { /* more code here */ }
Option d: private void foo() { /* more code here */ }
Option e: protected String foo() { /* more code here */ }
Option b: void foo() { /* more code here */ }
Select the most appropriate answer.
Given:
10. class One {
11. public One() { System.out.print(1); }
12. }
13. class Two extends One {
14. public Two() { System.out.print(2); }
15. }
16. class Three extends Two {
17. public Three() { System.out.print(3); }
18. }
19. public class Numbers{
20. public static void main( String[] argv) { new Three(); }
21. }
What is the result when this code is executed?
Option a: 1
Option b: 3
Option c: 123
Option d: 321
Option e: The code rims with no output.
Option c: 123
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.
Option a: (argument-list) == {body}
Option b: [{argument-list}] ->> {body}
Option c: {body} --> (argument-list)
Option d: (argument-list) ~> {body}
Option e: (argument-list) -> {body}
Made with
Easiest Website Builder