1Z0-808 Oracle Certified Associate Java SE8 Sample Questions
- CertiMaan
- Oct 27, 2025
- 23 min read
Updated: Dec 30, 2025
Prepare effectively for the Oracle Certified Associate Java SE8 1Z0-808 exam with our curated sample questions, practice tests, and mock exams. These resources are designed to mirror the official exam format and cover key topics like Java basics, object-oriented programming, flow control, arrays, and API classes. Ideal for aspiring Java developers, this comprehensive material ensures you're equipped to handle real exam scenarios. Whether you're using the 1Z0-808 dumps or seeking fresh practice exams, this set of resources offers the confidence and knowledge needed to pass the Java SE8 Associate certification with ease.
1Z0-808 Oracle Certified Associate Java SE8 Sample Questions List :
1. Consider below code of Test.java file: package com.udayan.oca; import java.util.ArrayList; import java.util.List; interface Sellable {} abstract class Animal {} class Mammal extends Animal{} class Rabbit extends Mammal implements Sellable{} public class Test { { List<Animal> list = new ArrayList<>(); list.add(new Rabbit()); } { List<Animal> list = new ArrayList<>(); list.add(new Mammal()); } { List<Mammal> list = new ArrayList<>(); list.add(new Rabbit()); } { List<Sellable> list = new ArrayList<>(); list.add(new Mammal()); } { List<Sellable> list = new ArrayList<>(); list.add(new Rabbit()); } } Which of the following statement is true?
Four initializer blocks cause compilation error.
Five initializer blocks cause compilation error.
Two initializer blocks cause compilation error.
Only one initializer block causes compilation error.
Three initializer blocks cause compilation error.
2. Given code of Test.java file: public class Test { public static void main(String[] args) { try { try { System.out.println(args[1]); //Line n1 } catch(RuntimeException e) { System.out.print("INHALE-"); //Line n2 throw e; //Line n3 } finally { System.out.print("EXHALE-"); //Line n4 } } catch(RuntimeException e) { System.out.print("INHALE-"); //Line n5 } finally { System.out.print("EXHALE"); //Line n6 } } } And the commands: javac Test.java java Test What is the result?
INHALE-EXHALE-INHALE-
INHALE-EXHALE-EXHALE
INHALE-EXHALE
INHALE-EXHALE-
INHALE-EXHALE-INHALE-EXHALE
3. Consider below code fragment: private void emp() {} And the statements: 1. Given code compiles successfully if it is used inside the class named 'emp' 2. Given code compiles successfully if it is used inside the class named 'Emp' 3. Given code compiles successfully if it is used inside the class named 'employee' 4. Given code compiles successfully if it is used inside the class named 'Employee' 5. Given code compiles successfully if it is used inside the class named 'Student' 6. Given code compiles successfully if it is used inside the class named '_emp_' How many statements are true?
Three statements
Only one statement
Four statements
Five statements
All six statements
Two statements
4. What will be the result of compiling and executing Test class package com.udayan.oca; import java.util.ArrayList; import java.util.List; public class Test { public static void main(String[] args) { List<String> fruits = new ArrayList<>(); fruits.add("apple"); fruits.add("orange"); fruits.add("grape"); fruits.add("mango"); fruits.add("banana"); fruits.add("grape"); if(fruits.remove("grape")) fruits.remove("apple"); System.out.println(fruits); } } ?
[orange, mango, banana, grape]
[orange, grape, mango, banana]
An exception is thrown at runtime
Compilation error
5. What will be the result of compiling and executing Circus //Circus.java package com.udayan.oca; class Animal { protected void jump() { System.out.println("Animal"); } } class Cat extends Animal { public void jump(int a) { System.out.println("Cat"); } } class Deer extends Animal { public void jump() { System.out.println("Deer"); } } public class Circus { public static void main(String[] args) { Animal cat = new Cat(); Animal deer = new Deer(); cat.jump(); deer.jump(); } } ?
Animal Deer
Cat Animal
Animal Animal
Cat Deer
6. package com.udayan.oca; class TestException extends Exception { public TestException() { super(); } public TestException(String s) { super(s); } } public class Test { public void m1() throws __________ { throw new TestException(); } } For the above code, fill in the blank with one option.?
Error
Exception
RuntimeException
Object
7. What will be the result of compiling and executing the following program package com.udayan.oca; import java.io.FileNotFoundException; import java.io.IOException; abstract class Super { public abstract void m1() throws IOException; } class Sub extends Super { @Override public void m1() throws IOException { throw new FileNotFoundException(); } } public class Test { public static void main(String[] args) { Super s = new Sub(); try { s.m1(); } catch (IOException e) { System.out.print("A"); } catch(FileNotFoundException e) { System.out.print("B"); } finally { System.out.print("C"); } } } ?
class Test gives compilation error
BC
AC
class Sub gives compilation error
8. Given code of Test.java file: package com.udayankhattry.oca; import java.util.ArrayList; import java.util.List; public class Test { public static void main(String[] args) { List<StringBuilder> list = new ArrayList<>(); list.add(new StringBuilder("AAA")); //Line n1 list.add(new StringBuilder("BBB")); //Line n2 list.add(new StringBuilder("AAA")); //Line n3 list.removeIf(sb -> sb.equals(new StringBuilder("AAA"))); //Line n4 System.out.println(list); } } What will be the result of compiling and executing Test class?
None of the other options
[BBB]
[AAA, BBB, AAA]
[BBB, AAA]
[]
9. Consider below code of Guest.java file: //Guest.java class Message { static void main(String [] args) { System.out.println("Welcome " + args[2] + "!"); } } public class Guest { public static void main(String [] args) { Message.main(args); } } And the commands: javac Guest.java java Guest Clare Waight Keller What is the result?
Welcome Clare!
Compilation error as main method is not public in Message class
ArrayIndexOutOfBoundsException is thrown at runtime
Some other error as main method can't be invoked manually
Welcome Waight!
Welcome Keller!
10. What will be the result of compiling and executing Test class package com.udayan.oca; public class Test { public static void main(String[] args) { Double [] arr = new Double[2]; System.out.println(arr[0] + arr[1]); } } ?
0.0
ClassCastException is thrown at runtime
Compilation error
NullPointerException is thrown at runtime
11. What will be the result of compiling and executing Test class package com.udayan.oca; public class Test { public static void main(String[] args) { System.out.println(new Boolean("ture")); } } ?
An exception is thrown at runtime
true
Compilation error
false
12. What will be the result of compiling and executing Test class //Test.java package com.udayan.oca; class Parent { int i = 10; Parent(int i) { super(); this.i = i; } } class Child extends Parent { int j = 20; Child(int j) { super(0); this.j = j; } Child(int i, int j) { super(i); this(j); } } public class Test { public static void main(String[] args) { Child child = new Child(1000, 2000); System.out.println(child.i + ":" + child.j); } } ?
Compilation error for Test class
1000:2000
1000:0
Compilation error for Parent(int) constructor
Compilation error for Child(int) constructor
Compilation error for Child(int, int) Constructor
13. Consider below code of Test.java file: package com.udayan.oca; class Document { int pages; Document(int pages) { this.pages = pages; } } class Word extends Document { String type; Word(String type) { super(20); //default pages /*INSERT-1*/ } Word(int pages, String type) { /*INSERT-2*/ super.pages = pages; } } public class Test { public static void main(String[] args) { Word obj = new Word(25, "TEXT"); System.out.println(obj.type + "," + obj.pages); } } Currently above code causes compilation error. Which of the options can successfully print TEXT,25 on to the console?
Replace /*INSERT-1*/ with: super.type = type; Replace /*INSERT-2*/ with: this(type);
Replace /*INSERT-1*/ with: super.type = type; Replace /*INSERT-2*/ with: super(type);
None of the other options
Replace /*INSERT-1*/ with: this.type = type; Replace /*INSERT-2*/ with: this(type);
Replace /*INSERT-1*/ with: this(type); Replace /*INSERT-2*/ with: this.type = type;
14. Consider below code: //Test.java package com.udayan.oca; import java.time.LocalDate; import java.time.LocalTime; public class Test { public static void main(String [] args) { LocalDate date = LocalDate.parse("1947-08-14"); LocalTime time = LocalTime.MAX; System.out.println(date.atTime(time)); } } What will be the result of compiling and executing Test class?
1947-08-14T23:59:59
1947-08-14T23:59:59.999999999
1947-08-14T23:59:59.0
1947-08-14T23:59:59.999
15. What will be the result of compiling and executing Test class package com.udayan.oca; public class Test { public static void main(String[] args) { String s1 = "OcA"; String s2 = "oCa"; System.out.println(s1.equals(s2)); } } ?
FALSE
TRUE
None of the other options
Compilation error
16. What will be the result of compiling and executing Bonus class? package com.udayan.oca; public class Bonus { public static void main(String[] args) { int $ = 80000; String msg = ($ >= 50000) ? "Good bonus" : "Average bonus"; System.out.println(msg); } }
Compilation error
Average bonus
Good bonus
17. What will be the result of compiling and executing Test class package com.udayan.oca; class A { A() { this(1); System.out.println("M"); } A(int i) { System.out.println("N"); } } class B extends A { } public class Test { public static void main(String[] args) { new B(); } } ?
N M
M N
N
M
18. Consider below code of Test.java file: package com.udayankhattry.oca; public class Test { public static void main(String[] args) { String arr1 [], arr2, arr3 = null; //Line n1 arr1 = new String[2]; arr1[0] = "A"; arr1[1] = "B"; arr2 = arr3 = arr1; //Line n2 log(arr2); //Line n3 } private static void log(String... vals) { for(String s : vals) System.out.print(s); } } What will be the result of compiling and executing Test class?
Line n1 causes compilation error
It executes successfully and prints AB on to the console
It executes successfully and prints BA on to the console
It executes successfully and prints B on to the console
Line n2 causes compilation error
It executes successfully and prints A on to the console
19. Consider the code of Test.java file: package com.udayan.oca; class Student { String name; int age; Student() { Student("James", 25); } Student(String name, int age) { this.name = name; this.age = age; } } public class Test { public static void main(String[] args) { Student s = new Student(); System.out.println(s.name + ":" + s.age); } } What will be the result of compiling and executing Test class?
null:0
James:25
An exception is thrown at runtime
Compilation error
20. What will be the result of compiling and executing Test class package com.udayan.oca; public class Test { public static void main(String[] args) { String [] arr = new String[7]; System.out.println(arr); } } ?
null
Compilation Error
Some String containing @ symbol
NullPointerException
21. Consider below codes of 3 java files: //Sellable.java package com.udayankhattry.oca; public interface Sellable { double getPrice(); default String symbol() { return "$"; } } //Chair.java package com.udayankhattry.oca; public class Chair implements Sellable { public double getPrice() { return 35; } public String symbol() { return "£"; } } //Test.java package com.udayankhattry.oca; public class Test { public static void main(String[] args) { Sellable obj = new Chair(); //Line n1 System.out.println(obj.symbol() + obj.getPrice()); //Line n2 } } What will be the result of compiling and executing Test class?
It compiles successfully and on execution prints $35.00 on to the console
It compiles successfully and on execution prints $35.0 on to the console
Compilation error in Test class
It compiles successfully and on execution prints £35 on to the console
Compilation error in Chair class
It compiles successfully and on execution prints £35.0 on to the console
22. Consider below codes of 3 java files: //Shrinkable.java package com.udayankhattry.oca; public interface Shrinkable { public static void shrinkPercentage() { System.out.println("80%"); } } //AntMan.java package com.udayankhattry.oca; public class AntMan implements Shrinkable { } //Test.java package com.udayankhattry.oca; public class Test { public static void main(String[] args) { AntMan.shrinkPercentage(); } } Which of the following statements is correct?
There is a compilation error in Shrinkable.java file
There is a compilation error in AntMan.java file
There is a compilation error in Test.java file
There is no compilation error and on execution, Test class prints 80% on to the console
23. Consider below code of Test.java file: package com.udayankhattry.oca; import java.time.LocalDate; public class Test { public static void main(String [] args) { LocalDate date = LocalDate.parse("2020-08-31"); System.out.println(date.plusMonths(-6)); } } What is the result?
2020-02-29
2020-02-31
An exception is thrown at runtime
Compilation error
2020-02-28
2020-02-30
24. Given the following definitions of the class Insect and the interface Flyable, the task is to declare a class Mosquito that inherits from the class Insect and implements the interface Flyable. class Insect {} interface Flyable {} Select the correct option to accomplish this task: ?
class Mosquito implements Insect extends Flyable{}
class Mosquito extends Insect, Flyable{}
class Mosquito extends Insect implements Flyable{}
class Mosquito implements Insect, Flyable{}
25. Which of the following are Java Exception classes Select 3 options. ?
NumberFormatException
IllegalArgumentException
ClassCastException
NullException
ArrayIndexException
26. Consider below code fragment: interface Printable { public void setMargin(); public void setOrientation(); } abstract class Paper implements Printable { //Line 7 public void setMargin() {} //Line 9 } class NewsPaper extends Paper { //Line 12 public void setMargin() {} //Line 14 } Above code is currently giving compilation error. Which 2 modifications, done independently, enable the code to compile?
Insert at Line 14: public void setOrientation() {}
Replace the code at Line 12 with: abstract class NewsPaper extends Paper {
Replace the code at Line 7 with: class Paper implements Printable {
Insert at Line 9: public abstract void setOrientation();
27. super keyword in java is used to:?
refer to static method of the class.
refer to current class object.
refer to static variable of the class.
refer to parent class object.
28. Consider below code of Test.java file: package com.udayankhattry.oca; public class Test { int i1 = 10; static int i2 = 20; private void change1(int val) { i1 = ++val; //Line n1 i2 = val++; //Line n2 } private static void change2(int val) { i1 = --val; //Line n3 i2 = val--; //Line n4 } public static void main(String[] args) { change1(5); //Line n5 change2(5); //Line n6 System.out.println(i1 + i2); //Line n7 } } Which of the following statements are correct regarding above code Select 3 options.?
Above code prints 30 on execution
Line n5 causes compilation error
Above code compiles successfully
Line n1 causes compilation error
Line n3 causes compilation error
Above code prints 8 on execution
29. Given code of Test.java file: package com.udayankhattry.oca; import java.io.FileNotFoundException; import java.io.IOException; class Base { Base() throws IOException { System.out.print(1); } } class Derived extends Base { Derived() throws FileNotFoundException { System.out.print(2); } } public class Test { public static void main(String[] args) throws Exception { new Derived(); } } What will be the result of compiling and executing Test class?
Test class executes successfully and prints 21 on to the console
Test class executes successfully and prints 12 on to the console
Compilation error only in Derived class
Compilation error in both Base and Derived classes
Compilation error only in Base class
30. What will be the result of compiling and executing Test class package com.udayan.oca; public class Test { public static void main(String[] args) { StringBuilder sb = new StringBuilder(); System.out.println(sb.append("").append("").append("").length()); } } ?
0
3
1
2
31. What is the signature of special main method?
public static void main(String [] a) {}
private static void main(String [] args) {}
public static void main(String args) {}
public static void main() {}
32. What will be the result of compiling and executing Test class package com.udayan.oca; import java.util.ArrayList; import java.util.List; public class Test { public static void main(String[] args) { Integer i = 10; List<Integer> list = new ArrayList<>(); list.add(i); list.add(new Integer(i)); list.add(i); list.removeIf(i -> i == 10); System.out.println(list); } } ?
Compilation Error
[10, 10]
[]
[10]
[10, 10, 10]
33. Consider below codes of 2 java files: //Flyable.java package com.udayankhattry.oca; public interface Flyable { static int horizontalDegree() { //Line n1 return 20; } default void fly() { System.out.println("Flying at " + horizontalDegree() + " degrees."); //Line n2 } void land(); } //Aeroplane.java package com.udayankhattry.oca; public class Aeroplane implements Flyable { public void land() { System.out.println("Landing at " + -Flyable.horizontalDegree() + " degrees."); //Line n3 } public static void main(String[] args) { new Aeroplane().fly(); new Aeroplane().land(); } } What will be the result of compiling and executing Aeroplane class?
Compilation error at Line n2
Given code compiles successfully and on execution prints below in the output: Flying at 20 degrees. Landing at -20 degrees.
Compilation error at Line n3
Compilation error at Line n1
34. For the given code: package com.udayan.oca; interface I01 { void m1(); } public class Implementer extends Object implements I01{ protected void m1() { } } ?
interface I01 gives compilation error as method m1 is not public.
Implementer class declaration is not correct.
None of the other options.
Method m1() in Implementer class is not implemented correctly.
35. Consider below code of Test.java file: package com.udayankhattry.oca; public class Test { public static void main(String [] args) { int num = 10; if(num++ == num++) { System.out.println("EQUAL " + num); } else { System.out.println("NOT EQUAL " + num); } } } What will be the result of compiling and executing Test class?
NOT EQUAL 11
NOT EQUAL 12
EQUAL 11
EQUAL 12
36. Which of the following correctly imports Animal class from com.masaimara package?
Import com.masaimara.Animal;
import com.masaimara.*;
import com.masaimara;
Import com.masaimara.*;
37. What will be the result of compiling and executing Test class package com.udayan.oca; public class Test { public static void main(String[] args) { int x = 5; while (x < 10) System.out.println(x); x++; } } ?
Produces no output
5 6 7 8 9
It will go in an infinite loop
Compilation error
38. Consider below code of TestBook.java file: package com.udayankhattry.oca; class Book { private String name; private String author; Book() {} Book(String name, String author) { name = name; author = author; } String getName() { return name; } String getAuthor() { return author; } } public class TestBook { public static void main(String[] args) { private Book book = new Book("Head First Java", "Kathy Sierra"); System.out.println(book.getName()); System.out.println(book.getAuthor()); } } What will be the result of compiling and executing above code?
Compilation error in Book class
Head First Java
Kathy Sierra
null
Compilation error in TestBook class
39. Which of the following is true for code below package com.udayan.oca; public class Test { public static void main(String[] args) { byte [] arr = new byte[0]; System.out.println(arr[0]); } } ?
Compilation error
ArrayIndexOutOfBoundsException
NullPointerException
0
40. What will be the result of compiling and executing Greetings class package com.udayan.oca; public class Greetings { String msg = null; public Greetings() { this("Good Morning!"); } public Greetings(String str) { msg = str; } public void display() { System.out.println(msg); } public static void main(String [] args) { Greetings g1 = new Greetings(); Greetings g2 = new Greetings("Good Evening!"); g1.display(); g2.display(); } } ?
null null
Good Morning! null
Good Morning! Good Evening!
null Good Evening!
41. Consider 2 files: //Counter.java package com.udayan.oca; public class Counter { public int count = 0; public Counter(int start) { count = start; } public int getCount() { return count; } public void increase(int val) { count = count + val; } public String toString() { return this.count + ""; } } //Test.java package com.udayan.oca.test; import java.util.Arrays; import com.udayan.oca.Counter; public class Test { public static void main(String[] args) { Counter[] arr = new Counter[] { new Counter(-1000), new Counter(539), new Counter(0) }; /* INSERT / System.out.println(Arrays.toString(arr)); } } Currently on executing Test class, output is: [-1000, 539, 0]. And below blocks: 1. for(Counter ctr : arr) { ctr.count = 100; } 2. for (Counter ctr : arr) { int x = ctr.getCount(); x = 100; } 3. for (Counter ctr : arr) { ctr.getCount() = 100; } 4. for(Counter ctr : arr) { ctr.increase(100 - ctr.count); } 5. for (Counter ctr : arr) { ctr.increase(100 - ctr.getCount()); } 6. for(Counter ctr : arr) { ctr.increase(-ctr.getCount() + 100); } 7. for(Counter ctr : arr) { ctr.increase(-ctr.count + 100); } How many blocks can replace /INSERT*/ such that output is: [100, 100, 100]?
Only Two blocks
Only Three blocks
Only Four blocks
Only One block
Only Six blocks
Only Five blocks
42. Consider below code of Test.java file: package com.udayankhattry.oca; public class Test { public static void main(String[] args) { int x = 10; //Line n1 if (false) System.out.println(x); //Line n2 System.out.println("HELLO"); //Line n3 } } What is the result of compiling and executing Test class?
HELLO
Compilation error at Line n1
Compilation error at Line n2
10 HELLO
Compilation error at Line n3
43. Consider the code of Test.java file: package com.udayankhattry.oca; public class Test { private static void m(int i) { System.out.print(1); } private static void m(int i1, int i2) { System.out.print(2); } private static void m(char... args) { System.out.print(3); } public static void main(String... args) { m('A'); m('A', 'B'); m('A', 'B', 'C'); m('A', 'B', 'C', 'D'); } } What will be the result of compiling and executing Test class?
Above code causes compilation error
It compiles successfully and on execution prints 3333 on to the console
It compiles successfully and on execution prints 1233 on to the console
It compiles successfully and on execution prints 1333 on to the console
44. What will be the result of compiling and executing Greetings class package com.udayan.oca; public class Greetings { String msg = null; public Greetings() { } public Greetings(String str) { msg = str; } public void display() { System.out.println(msg); } public static void main(String [] args) { Greetings g1 = new Greetings(); Greetings g2 = new Greetings("Good Evening!"); g1.display(); g1.display(); } } ?
null null
Compilation error
Good Evening! null
null Good Evening!
45. Consider codes below: //A.java package com.udayan.oca; public class A { public int i1 = 1; protected int i2 = 2; } //B.java package com.udayan.oca.test; import com.udayan.oca.A; public class B extends A { public void print() { A obj = new A(); System.out.println(obj.i1); //Line 8 System.out.println(obj.i2); //Line 9 System.out.println(this.i2); //Line 10 System.out.println(super.i2); //Line 11 } public static void main(String [] args) { new B().print(); } } One of the statements inside print() method is causing compilation failure. Which of the below solutions will help to resolve compilation error?
Comment the statement at Line 8
Comment the statement at Line 10
Comment the statement at Line 11
Comment the statement at Line 9
46. Consider below code: package com.udayan.oca; public class Test { static Double d1; int x = d1.intValue(); public static void main(String[] args) { System.out.println("HELLO"); } } On execution, does Test class print "HELLO" on to the console?
Yes, HELLO is printed on to the console
No, HELLO is not printed on to the console
47. Given code: package com.udayan.oca; public class Test { public static void main(String[] args) { Boolean [] arr = new Boolean[2]; System.out.println(arr[0] + ":" + arr[1]); } } What is the result?
NullPointerException is thrown at runtime
true:true
null:null
false:false
48. Consider below code: //Test.java package com.udayan.oca; public class Test { public static void main(String[] args) { final int i1 = 1; final Integer i2 = 1; final String s1 = ":ONE"; String str1 = i1 + s1; String str2 = i2 + s1; System.out.println(str1 == "1:ONE"); System.out.println(str2 == "1:ONE"); } } What will be the result of compiling and executing Test class?
true false
true true
false false
false true
49. Consider below code: //Test.java import java.time.LocalDate; import java.time.format.DateTimeFormatter; public class Test { public static void main(String [] args) { LocalDate date = LocalDate.of(1987, 9, 1); String str = date.format(DateTimeFormatter.ISO_DATE_TIME); System.out.println("Date is: " + str); } } What will be the result of compiling and executing Test class?
Date is: 1987-09-01
Date is: 1987-01-09
Date is: 01-09-1987
Given code executes successfully but output does not match with the given options
Runtime exception
50. Range of short data type is from -32768 to 32767 Which of the following code segments, written inside main method will compile successfully Select 3 options.?
final int i5 = 10; short s5 = i5 + 100;
short s1 = 10;
final int i4 = 40000; short s4 = i4;
short s2 = 32768;
int i7 = 10; short s7 = i7;
final int i3 = 10; short s3 = i3;
51. What will be the result of compiling and executing Test class package com.udayan.oca; import java.util.ArrayList; import java.util.List; public class Test { public static void main(String[] args) { List<Integer> list = new ArrayList<>(); list.add(100); list.add(200); list.add(100); list.add(200); list.remove(new Integer(100)); System.out.println(list); } } ?
Compilation error
[200, 200]
[200]
Exception is thrown at runtime
[200, 100, 200]
[100, 200, 200]
52. What will be the result of compiling and executing Test class package com.udayan.oca; public class Test { public static void main(String[] args) { double price = 90000; String model; if(price > 100000) { model = "Tesla Model X"; } else if(price <= 100000) { model = "Tesla Model S"; } System.out.println(model); } } ?
Tesla Model S
Tesla Model X
null
Compilation Error
53. Consider below code: package com.udayan.oca; public class Test { private static void add(int i, int j) { System.out.println("int version"); } private static void add(Integer i, Integer j) { System.out.println("Integer version"); } public static void main(String[] args) { add(10, 20); } } Which modifications, done independently, print "Integer version" on to the console Select 3 options.?
Replace add(10, 20); by add(new Integer(10), new Integer(20));
Replace add(10, 20); by add(null, null);
Remove add(int i, int j) method declaration and definition.
Replace add(10, 20); by add(10.0, 20.0);
54. Consider below code: package com.udayan.oca; public class Counter { int count; private static void increment(Counter counter) { counter.count++; } public static void main(String [] args) { Counter c1 = new Counter(); Counter c2 = c1; Counter c3 = null; c2.count = 1000; increment(c2); } } On executing Counter class, how many Counter objects are created in the memory?
4
3
1
2
55. Consider below code: //Test.java package com.udayan.oca; class SpecialString { String str; SpecialString(String str) { this.str = str; } } public class Test { public static void main(String[] args) { Object [] arr = new Object[4]; for(int i = 1; i <=3; i++) { switch(i) { case 1: arr[i] = new String("Java"); break; case 2: arr[i] = new StringBuilder("Java"); break; case 3: arr[i] = new SpecialString("Java"); break; } } for(Object obj : arr) { System.out.println(obj); } } } What will be the result of compiling and executing Test class?
Java <Some text containing @ symbol> <Some text containing @ symbol> null
Java Java <Some text containing @ symbol> null
Java Java <Some text containing @ symbol>
Java Java Java
Java <Some text containing @ symbol> <Some text containing @ symbol>
null Java Java <Some text containing @ symbol>
56. Given code of Test.java file: package com.udayankhattry.oca; import java.sql.SQLException; public class Test { private static void availableSeats() throws SQLException { throw null; //Line 7 } public static void main(String[] args) { try { availableSeats(); //Line 12 } catch(SQLException e) { System.out.println("SEATS NOT AVAILABLE"); } } } What will be the result of compiling and executing Test class?
Line 12 causes compilation failure
Line 7 causes compilation failure
SEATS NOT AVAILABLE is printed on to the console and program terminates successfully
Program ends abruptly
57. Below is the code of Test.java file: package com.udayan.oca; import java.util.ArrayList; import java.util.List; public class Test { public static void main(String [] args) { List<Integer> list = new ArrayList<Integer>(); list.add(new Integer(2)); list.add(new Integer(1)); list.add(new Integer(0)); list.remove(list.indexOf(0)); System.out.println(list); } } What will be the result of compiling and executing Test class?
Compilation error
[1, 0]
[2, 1]
An exception is thrown at runtime
58. Given code of Test.java file: package com.udayankhattry.oca; import java.util.ArrayList; import java.util.List; import java.util.function.Predicate; public class Test { public static void main(String[] args) { List<String> words = new ArrayList<>(); words.add("A"); words.add("an"); words.add("the"); words.add("when"); words.add("what"); words.add("Where"); words.add("whether"); processStringArray(words, /*INSERT*/); } private static void processStringArray(List<String> list, Predicate<String> predicate) { for(String str : list) { if(predicate.test(str)) { System.out.println(str); } } } } Which of the following options can replace /*INSERT*/ such that on executing Test class all the list elements are displayed in the output Select 4 options.?
String p -> p.length() > 0
p -> !!false
p -> true
p -> !!!!true
p -> p.length() < 7
(String p) -> p.length() < 100
59. What will be the result of compiling and executing Test class package com.udayan.oca; public class Test { public static void main(String[] args) { int i; outer: do { i = 5; inner: while (true) { System.out.println(i--); if (i == 4) { break outer; } } } while (true); } } ?
Prints 5 once.
5 3 2 1
Prints 5 in an infinite loop.
Compilation error.
60. Given code of Test.java file: package com.udayankhattry.oca; import java.io.IOException; class Parent { Parent() throws IOException { System.out.print("HAKUNA"); } } class Child extends Parent { Child() throws Exception { System.out.println("MATATA"); } } public class Test { public static void main(String[] args) throws Exception { new Child(); } } What will be the result of compiling and executing Test class?
Compilation error only in Parent class
Test class executes successfully and prints HAKUNAMATATA on to the console
Test class executes successfully and prints MATATAHAKUNA on to the console
Compilation error only in Child class
Compilation error in both Parent and Child classes
61. Consider below code of Test.java file: package com.udayankhattry.oca; public class Test { public static void main(String[] args) { P p = new R(); //Line n1 System.out.println(p.compute("Go")); //Line n2 } } class P { String compute(String str) { return str + str + str; } } class Q extends P { String compute(String str) { return super.compute(str.toLowerCase()); } } class R extends Q { String compute(String str) { return super.compute(str.replace('o', 'O')); //2nd argument is uppercase O } } What will be the result of compiling and executing Test class?
Go
GO
GoGoGo
GOGOGO
go
gogogo
62. What will be the result of compiling and executing Test class package com.udayan.oca; public class Test { public static void main(String[] args) { StringBuilder sb = new StringBuilder(); System.out.println(sb.append(null).length()); } } ?
1
NullPointerException is thrown at runtime
Compilation error
4
63. Consider below code: //Test.java package com.udayan.oca; import java.time.Period; public class Test { public static void main(String [] args) { Period period = Period.of(0, 1000, 0); System.out.println(period); } } What will be the result of compiling and executing Test class?
p0y1000m0d
P1000M
P0Y1000M0D
p1000m
64. What will be the result of compiling and executing Test class package com.udayan.oca; public class Test { public static void print() { System.out.println("static method"); } public static void main(String[] args) { Test obj = null; obj.print(); } } ?
None of the other options
Compilation error
static method
NullPointerException is thrown
65. Given code of Test.java file: package com.udayankhattry.oca; interface Document { default String getType() { return "TEXT"; } } interface WordDocument extends Document { String getType(); } class Word implements WordDocument {} public class Test { public static void main(String[] args) { Document doc = new Word(); //Line n1 System.out.println(doc.getType()); //Line n2 } } Which of the following statements is correct?
Interface WordDocument causes compilation error
Test class compiles successfully and on execution prints TEXT on to the console
Interface Document causes compilation error
Class Word causes compilation error
66. Consider below code: //Test.java package com.udayan.oca; import java.util.ArrayList; import java.util.List; public class Test { public static void main(String[] args) { List<Boolean> list = new ArrayList<>(); list.add(true); list.add(new Boolean("tRue")); list.add(new Boolean("abc")); if(list.remove(1)) { list.remove(1); } System.out.println(list); } } What will be the result of compiling and executing Test class?
Compilation error
An exception is thrown at runtime
[true, false]
[true]
[false]
67. What will be the result of compiling and executing Test class package com.udayan.oca; public class Test extends String { @Override public String toString() { return "TEST"; } public static void main(String[] args) { Test obj = new Test(); System.out.println(obj); } } ?
TEST
Compilation error
Output string contains @ symbol
Exception is thrown at runtime
68. Given code of Test.java file: package com.udayankhattry.oca; class Base { String msg = "INHALE"; //Line n1 } class Derived extends Base { Object msg = "EXHALE"; //Line n2 } public class Test { public static void main(String[] args) { Base obj1 = new Base(); //Line n3 Base obj2 = new Derived(); //Line n4 Derived obj3 = (Derived) obj2; //Line n5 String text = obj1.msg + "-" + obj2.msg + "-" + obj3.msg; //Line n6 System.out.println(text); //Line n7 } } What will be the result of compiling and executing above code?
Line n5 throws Exception at runtime
Line n2 causes compilation error
It executes successfully and prints INHALE-INHALE-INHALE
It executes successfully and prints INHALE-EXHALE-EXHALE
It executes successfully and prints INHALE-INHALE-EXHALE
None of the other options
69. What will be the result of compiling and executing Test class package com.udayan.oca; public class Test { public static void main(String[] args) { int a = 7; boolean res = a++ == 7 && ++a == 9 || a++ == 9; System.out.println("a = " + a); System.out.println("res = " + res); } } ?
a = 10 res = false
a = 9 res = true
Compilation error
a = 10 res = true
70. Consider below code: //Test.java package com.udayan.oca; import java.util.ArrayList; import java.util.List; public class Test { public static void main(String[] args) { List<String> trafficLight = new ArrayList<>(); trafficLight.add(1, "RED"); trafficLight.add(2, "ORANGE"); trafficLight.add(3, "GREEN"); trafficLight.remove(new Integer(2)); System.out.println(trafficLight); } } What will be the result of compiling and executing Test class?
[RED, ORANGE, GREEN]
[RED, GREEN]
[RED, ORANGE]
Compilation error
An exception is thrown at runtime
71. Given code of Test.java file: package com.udayankhattry.oca; public class Test { public static void main(String[] args) { byte b1 = 10; //Line n1 int i1 = b1; //Line n2 byte b2 = i1; //Line n3 System.out.println(b1 + i1 + b2); } } What is the result of compiling and executing Test class?
Line n3 causes compilation error
Line n1 causes compilation error
30 is printed on to the console
Line n2 causes compilation error
72. Consider below code of Test.java file: public class Test { public static void main(String [] args) { System.out.println("String"); } public static void main(Integer [] args) { System.out.println("Integer"); } public static void main(byte [] args) { System.out.println("byte"); } } And the commands: javac Test.java java Test 10 What is the result?
String
An Exception is thrown at runtime
byte
Compilation error
Integer
73. What will be the result of compiling and executing Test class package com.udayan.oca; public class Test { private static void m(int x) { System.out.println("int version"); } private static void m(char x) { System.out.println("char version"); } public static void main(String [] args) { int i = '5'; m(i); m('5'); } } ?
int version char version
char version int version
char version char version
Compilation error
int version int version
74. Which of the following statement declares a constant field in Java?
int x = 10;
static int x = 10;
final static int x = 10;
const int x = 10;
75. Consider below code: //Guest.java class Message { public static void main(String [] args) { System.out.println("Welcome " + args[0] + "!"); } } public class Guest { public static void main(String [] args) { Message.main(args); } } And the commands: javac Guest.java java Guest James Gosling What is the result?
ArrayIndexOutOfBoundsException is thrown at runtime
Some other error as main method can't be invoked manually
Welcome James!
Welcome Gosling!
FAQs
1. What is the Oracle Certified Associate Java SE 8 Programmer 1Z0-808 certification?
The Oracle 1Z0-808 certification validates your fundamental knowledge of Java programming, including object-oriented principles, syntax, and core Java concepts for building robust applications.
2. How do I become an Oracle Certified Associate Java SE 8 certified professional?
You must pass the 1Z0-808: Java SE 8 Programmer I exam, which measures your ability to code, debug, and use Java to create object-oriented applications.
3. What are the prerequisites for the Oracle Java SE 8 1Z0-808 exam?
There are no formal prerequisites. However, familiarity with basic programming concepts and Java syntax is highly recommended before attempting the exam.
4. How much does the Oracle Certified Associate Java SE 8 1Z0-808 exam cost?
The exam costs around $245 USD, though prices may vary based on region and currency.
5. How many questions are in the Oracle 1Z0-808 exam, and what is the time limit?
The exam includes 70 multiple-choice questions, and you’ll have 150 minutes to complete it.
6. What topics are covered in the Oracle Certified Associate Java SE 8 certification exam?
Key topics include Java basics, object-oriented programming, operators, loops, arrays, methods, inheritance, and exception handling.
7. How difficult is the Oracle Certified Associate Java SE 8 1Z0-808 exam?
It’s considered a beginner to intermediate-level certification, suitable for new programmers looking to start their career in Java development.
8. How long does it take to prepare for the Oracle Java SE 8 1Z0-808 certification exam?
Most candidates prepare in 6–10 weeks, depending on their prior Java knowledge and hands-on coding experience.
9. What jobs can I get after earning the Oracle Certified Associate Java SE 8 certification?
You can work as a Java Developer, Software Engineer, Application Developer, or Junior Programmer in software development companies.
10. What is the average salary of an Oracle Certified Associate Java SE 8 certified professional?
Certified Java professionals typically earn between $80,000–$110,000 per year, depending on experience and role.

Comments