top of page

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?

  1. Four initializer blocks cause compilation error.

  2. Five initializer blocks cause compilation error.

  3. Two initializer blocks cause compilation error.

  4. Only one initializer block causes compilation error.

  5. 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?

  1. INHALE-EXHALE-INHALE-

  2. INHALE-EXHALE-EXHALE

  3. INHALE-EXHALE

  4. INHALE-EXHALE-

  5. 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?

  1. Three statements

  2. Only one statement

  3. Four statements

  4. Five statements

  5. All six statements

  6. 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); } } ?

  1. [orange, mango, banana, grape]

  2. [orange, grape, mango, banana]

  3. An exception is thrown at runtime

  4. 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(); } } ?

  1. Animal Deer

  2. Cat Animal

  3. Animal Animal

  4. 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.?

  1. Error

  2. Exception

  3. RuntimeException

  4. 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"); } } } ?

  1. class Test gives compilation error

  2. BC

  3. AC

  4. 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?

  1. None of the other options

  2. [BBB]

  3. [AAA, BBB, AAA]

  4. [BBB, AAA]

  5. []

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?

  1. Welcome Clare!

  2. Compilation error as main method is not public in Message class

  3. ArrayIndexOutOfBoundsException is thrown at runtime

  4. Some other error as main method can't be invoked manually

  5. Welcome Waight!

  6. 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]); } } ?

  1. 0.0

  2. ClassCastException is thrown at runtime

  3. Compilation error

  4. 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")); } } ?

  1. An exception is thrown at runtime

  2. true

  3. Compilation error

  4. 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); } } ?

  1. Compilation error for Test class

  2. 1000:2000

  3. 1000:0

  4. Compilation error for Parent(int) constructor

  5. Compilation error for Child(int) constructor

  6. 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?

  1. Replace /*INSERT-1*/ with: super.type = type; Replace /*INSERT-2*/ with: this(type);

  2. Replace /*INSERT-1*/ with: super.type = type; Replace /*INSERT-2*/ with: super(type);

  3. None of the other options

  4. Replace /*INSERT-1*/ with: this.type = type; Replace /*INSERT-2*/ with: this(type);

  5. 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?

  1. 1947-08-14T23:59:59

  2. 1947-08-14T23:59:59.999999999

  3. 1947-08-14T23:59:59.0

  4. 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)); } } ?

  1. FALSE

  2. TRUE

  3. None of the other options

  4. 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); } }

  1. Compilation error

  2. Average bonus

  3. 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(); } } ?

  1. N M

  2. M N

  3. N

  4. 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?

  1. Line n1 causes compilation error

  2. It executes successfully and prints AB on to the console

  3. It executes successfully and prints BA on to the console

  4. It executes successfully and prints B on to the console

  5. Line n2 causes compilation error

  6. 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?

  1. null:0

  2. James:25

  3. An exception is thrown at runtime

  4. 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); } } ?

  1. null

  2. Compilation Error

  3. Some String containing @ symbol

  4. 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?

  1. It compiles successfully and on execution prints $35.00 on to the console

  2. It compiles successfully and on execution prints $35.0 on to the console

  3. Compilation error in Test class

  4. It compiles successfully and on execution prints £35 on to the console

  5. Compilation error in Chair class

  6. 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?

  1. There is a compilation error in Shrinkable.java file

  2. There is a compilation error in AntMan.java file

  3. There is a compilation error in Test.java file

  4. 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?

  1. 2020-02-29

  2. 2020-02-31

  3. An exception is thrown at runtime

  4. Compilation error

  5. 2020-02-28

  6. 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: ?

  1. class Mosquito implements Insect extends Flyable{}

  2. class Mosquito extends Insect, Flyable{}

  3. class Mosquito extends Insect implements Flyable{}

  4. class Mosquito implements Insect, Flyable{}

25. Which of the following are Java Exception classes Select 3 options. ?

  1. NumberFormatException

  2. IllegalArgumentException

  3. ClassCastException

  4. NullException

  5. 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?

  1. Insert at Line 14: public void setOrientation() {}

  2. Replace the code at Line 12 with: abstract class NewsPaper extends Paper {

  3. Replace the code at Line 7 with: class Paper implements Printable {

  4. Insert at Line 9: public abstract void setOrientation();

27. super keyword in java is used to:?

  1. refer to static method of the class.

  2. refer to current class object.

  3. refer to static variable of the class.

  4. 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.?

  1. Above code prints 30 on execution

  2. Line n5 causes compilation error

  3. Above code compiles successfully

  4. Line n1 causes compilation error

  5. Line n3 causes compilation error

  6. 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?

  1. Test class executes successfully and prints 21 on to the console

  2. Test class executes successfully and prints 12 on to the console

  3. Compilation error only in Derived class

  4. Compilation error in both Base and Derived classes

  5. 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()); } } ?

  1. 0

  2. 3

  3. 1

  4. 2

31. What is the signature of special main method?

  1. public static void main(String [] a) {}

  2. private static void main(String [] args) {}

  3. public static void main(String args) {}

  4. 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); } } ?

  1. Compilation Error

  2. [10, 10]

  3. []

  4. [10]

  5. [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?

  1. Compilation error at Line n2

  2. Given code compiles successfully and on execution prints below in the output: Flying at 20 degrees. Landing at -20 degrees.

  3. Compilation error at Line n3

  4. 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() { } } ?

  1. interface I01 gives compilation error as method m1 is not public.

  2. Implementer class declaration is not correct.

  3. None of the other options.

  4. 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?

  1. NOT EQUAL 11

  2. NOT EQUAL 12

  3. EQUAL 11

  4. EQUAL 12

36. Which of the following correctly imports Animal class from com.masaimara package?

  1. Import com.masaimara.Animal;

  2. import com.masaimara.*;

  3. import com.masaimara;

  4. 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++; } } ?

  1. Produces no output

  2. 5 6 7 8 9

  3. It will go in an infinite loop

  4. 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?

  1. Compilation error in Book class

  2. Head First Java

  3. Kathy Sierra

  4. null

  5. 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]); } } ?

  1. Compilation error

  2. ArrayIndexOutOfBoundsException

  3. NullPointerException

  4. 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(); } } ?

  1. null null

  2. Good Morning! null

  3. Good Morning! Good Evening!

  4. 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]?

  1. Only Two blocks

  2. Only Three blocks

  3. Only Four blocks

  4. Only One block

  5. Only Six blocks

  6. 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?

  1. HELLO

  2. Compilation error at Line n1

  3. Compilation error at Line n2

  4. 10 HELLO

  5. 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?

  1. Above code causes compilation error

  2. It compiles successfully and on execution prints 3333 on to the console

  3. It compiles successfully and on execution prints 1233 on to the console

  4. 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(); } } ?

  1. null null

  2. Compilation error

  3. Good Evening! null

  4. 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?

  1. Comment the statement at Line 8

  2. Comment the statement at Line 10

  3. Comment the statement at Line 11

  4. 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?

  1. Yes, HELLO is printed on to the console

  2. 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?

  1. NullPointerException is thrown at runtime

  2. true:true

  3. null:null

  4. 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?

  1. true false

  2. true true

  3. false false

  4. 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?

  1. Date is: 1987-09-01

  2. Date is: 1987-01-09

  3. Date is: 01-09-1987

  4. Given code executes successfully but output does not match with the given options

  5. 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.?

  1. final int i5 = 10; short s5 = i5 + 100;

  2. short s1 = 10;

  3. final int i4 = 40000; short s4 = i4;

  4. short s2 = 32768;

  5. int i7 = 10; short s7 = i7;

  6. 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); } } ?

  1. Compilation error

  2. [200, 200]

  3. [200]

  4. Exception is thrown at runtime

  5. [200, 100, 200]

  6. [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); } } ?

  1. Tesla Model S

  2. Tesla Model X

  3. null

  4. 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.?

  1. Replace add(10, 20); by add(new Integer(10), new Integer(20));

  2. Replace add(10, 20); by add(null, null);

  3. Remove add(int i, int j) method declaration and definition.

  4. 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?

  1. 4

  2. 3

  3. 1

  4. 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?

  1. Java <Some text containing @ symbol> <Some text containing @ symbol> null

  2. Java Java <Some text containing @ symbol> null

  3. Java Java <Some text containing @ symbol>

  4. Java Java Java

  5. Java <Some text containing @ symbol> <Some text containing @ symbol>

  6. 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?

  1. Line 12 causes compilation failure

  2. Line 7 causes compilation failure

  3. SEATS NOT AVAILABLE is printed on to the console and program terminates successfully

  4. 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?

  1. Compilation error

  2. [1, 0]

  3. [2, 1]

  4. 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.?

  1. String p -> p.length() > 0

  2. p -> !!false

  3. p -> true

  4. p -> !!!!true

  5. p -> p.length() < 7

  6. (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); } } ?

  1. Prints 5 once.

  2. 5 3 2 1

  3. Prints 5 in an infinite loop.

  4. 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?

  1. Compilation error only in Parent class

  2. Test class executes successfully and prints HAKUNAMATATA on to the console

  3. Test class executes successfully and prints MATATAHAKUNA on to the console

  4. Compilation error only in Child class

  5. 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?

  1. Go

  2. GO

  3. GoGoGo

  4. GOGOGO

  5. go

  6. 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. 1

  2. NullPointerException is thrown at runtime

  3. Compilation error

  4. 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?

  1. p0y1000m0d

  2. P1000M

  3. P0Y1000M0D

  4. 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(); } } ?

  1. None of the other options

  2. Compilation error

  3. static method

  4. 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?

  1. Interface WordDocument causes compilation error

  2. Test class compiles successfully and on execution prints TEXT on to the console

  3. Interface Document causes compilation error

  4. 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?

  1. Compilation error

  2. An exception is thrown at runtime

  3. [true, false]

  4. [true]

  5. [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); } } ?

  1. TEST

  2. Compilation error

  3. Output string contains @ symbol

  4. 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?

  1. Line n5 throws Exception at runtime

  2. Line n2 causes compilation error

  3. It executes successfully and prints INHALE-INHALE-INHALE

  4. It executes successfully and prints INHALE-EXHALE-EXHALE

  5. It executes successfully and prints INHALE-INHALE-EXHALE

  6. 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); } } ?

  1. a = 10 res = false

  2. a = 9 res = true

  3. Compilation error

  4. 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?

  1. [RED, ORANGE, GREEN]

  2. [RED, GREEN]

  3. [RED, ORANGE]

  4. Compilation error

  5. 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?

  1. Line n3 causes compilation error

  2. Line n1 causes compilation error

  3. 30 is printed on to the console

  4. 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?

  1. String

  2. An Exception is thrown at runtime

  3. byte

  4. Compilation error

  5. 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'); } } ?

  1. int version char version

  2. char version int version

  3. char version char version

  4. Compilation error

  5. int version int version

74. Which of the following statement declares a constant field in Java?

  1. int x = 10;

  2. static int x = 10;

  3. final static int x = 10;

  4. 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?

  1. ArrayIndexOutOfBoundsException is thrown at runtime

  2. Some other error as main method can't be invoked manually

  3. Welcome James!

  4. 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.


Recent Posts

See All

Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating
CertiMaan Logo

​​

Terms Of Use     |      Privacy Policy     |      Refund Policy    

   

 Copyright © 2011 - 2026  Ira Solutions -   All Rights Reserved

Disclaimer:: 

The content provided on this website is for educational and informational purposes only. We do not claim any affiliation with official certification bodies, including but not limited to Pega, Microsoft, AWS, IBM, SAP , Oracle , PMI, or others.

All practice questions, study materials, and dumps are intended to help learners understand exam patterns and enhance their preparation. We do not guarantee certification results and discourage the misuse of these resources for unethical purposes.

PayU logo
Razorpay logo
bottom of page