Mock Exam

Oracle 1Z0-808 – Practice Test – 1

Welcome to the Oracle 1z0-808 Mock Exam. This exam is designed to evaluate your knowledge and skills in Java Basics

How can we help you?​

Welcome to the Oracle 1z0-808 Mock Exam. This exam is designed to evaluate your knowledge and skills in Java Basics, Using Operators and Decision Constructs, Loop Constructs, Inheritance, selected classes from the Java API (String, StringBuilder, calendar data, ArrayList, Lambda), Java Data Types, Creating and Using Arrays, Methods and Encapsulation, and Handling Exceptions. This test will help you to prepare for the Oracle 1z0-808 certification exam, this test is a valuable resource.

Test your Oracle skills with our mock exams. Best of luck!

These mock exams or assessments provide you the impression of the actual Oracle Certification exams. There is no fee for these assessments and these will allow you to evaluate your understanding of Oracle. The assessment results will guide you around your areas where you to need to learn or focus more.

We are in the process of updating the questions as a routine monthly amendments.

0%

Oracle 1Z0-808 - Practice Test - 1

Please fill the form:

1 / 15

When does a class get the default constructor?

 

 

2 / 15

What will be the result of compiling and executing Test class?

  1. //Test.java
  2. package com.udayan.oca;
  3. import java.io.FileNotFoundException;
  4. public class Test {
  5. public static void main(String[] args) {
  6. try {
  7. System.out.println(1);
  8. } catch (NullPointerException ex) {
  9. System.out.println("ONE");
  10. } catch (FileNotFoundException ex) {
  11. System.out.println("TWO");
  12. }
  13. System.out.println("THREE");
  14. }
  15. }

 

3 / 15

What will be the result of compiling and executing Test class?

  1. package com.udayan.oca;
  2.  
  3. class Base {
  4.     public void m1() throws NullPointerException {
  5.         System.out.println("Base: m1()");
  6.     }
  7. }
  8.  
  9. class Derived extends Base {
  10.     public void m1() throws RuntimeException {
  11.         System.out.println("Derived: m1()");
  12.     }
  13. }
  14.  
  15. public class Test {
  16.     public static void main(String[] args) {
  17.         Base obj = new Derived();
  18.          obj.m1();
  19.     }
  20. }

 

4 / 15

  1. package com.udayan.oca;
  2. class TestException extends Exception {
  3. public TestException() {
  4. super();
  5. }
  6. public TestException(String s) {
  7. super(s);
  8. }
  9. }
  10. public class Test {
  11. public void m1() throws __________ {
  12. throw new TestException();
  13. }
  14. }

For the above code, fill in the blank with one option.

 

5 / 15

Consider below code:

  1. //Test.java
  2. package com.udayan.oca;
  3.  
  4. import java.time.LocalDate;
  5. import java.time.Month;
  6. import java.time.Period;
  7.  
  8. public class Test {
  9.     public static void main(String [] args) {
  10.         LocalDate date = LocalDate.of(2000, Month.JANUARY, 1);
  11.         Period period = Period.parse("p-30000y");
  12.         System.out.println(date.plus(period));
  13.     }
  14. }

What will be the result of compiling and executing Test class?

6 / 15

What will be the result of compiling and executing Test class?

  1. package com.udayan.oca;
  2. public class Test {
  3. public static void main(String[] args) {
  4. int start = 1;
  5. int sum = 0;
  6. do {
  7. if(start % 2 == 0) {
  8. continue;
  9. }
  10.             sum += start;
  11. } while(++start <= 10);
  12. System.out.println(sum);
  13. }
  14. }

 

7 / 15

Suppose you have created a java file, "MyClass.java". Which of the following commands will compile the java file?

 

 

8 / 15

Consider below code:

  1. //Test.java
  2. package com.udayan.oca;
  3. import java.util.ArrayList;
  4. import java.util.List;
  5. class Student {
  6. private String name;
  7. private int age;
  8. Student(String name, int age) {
  9. this.name = name;
  10. this.age = age;
  11. }
  12. public String toString() {
  13. return "Student[" + name + ", " + age + "]";
  14. }
  15. public boolean equals(Student obj) {
  16. if(obj instanceof Student) {
  17. Student stud = (Student)obj;
  18. if(this.name.equals(stud.name) && this.age == stud.age) {
  19. return true;
  20. }
  21. }
  22. return false;
  23. }
  24. }
  25. public class Test {
  26. public static void main(String[] args) {
  27. List<Student> students = new ArrayList<>();
  28.         students.add(new Student("James", 25));
  29.         students.add(new Student("James", 27));
  30.         students.add(new Student("James", 25));
  31.         students.add(new Student("James", 25));
  32.         students.remove(new Student("James", 25));
  33. for(Student stud : students) {
  34. System.out.println(stud);
  35. }
  36. }
  37. }

What will be the result of compiling and executing Test class?

 

9 / 15

What will be the result of compiling and executing Test class?

  1. package com.udayan.oca;
  2. public class Test extends String {
  3. @Override
  4. public String toString() {
  5. return "TEST";
  6. }
  7. public static void main(String[] args) {
  8. Test obj = new Test();
  9. System.out.println(obj);
  10. }
  11. }

 

10 / 15

Given code:

  1. package com.udayan.oca;
  2. public class Test {
  3. public static void main(String[] args) {
  4. int [] arr = {1, 2, 3, 4, 5};
  5. int x = 0;
  6. for(/*INSERT*/) {
  7.             x += arr[n];
  8. }
  9. System.out.println(x);
  10. }
  11. }

Which 3 options, if used to replace /*INSERT*/, on execution will print 9 on to the console?

 

11 / 15

What will be the result of compiling and executing Test class?

  1. package com.udayan.oca;
  2. import java.util.ArrayList;
  3. import java.util.List;
  4. public class Test {
  5. public static void main(String[] args) {
  6. List<Integer> list = new ArrayList<>();
  7.         list.add(110);
  8.         list.add(new Integer(110));
  9.         list.add(110);
  10.         list.removeIf(i -> i == 110);
  11. System.out.println(list);
  12. }
  13. }

 

12 / 15

Consider below code:

  1. //Test.java
  2. package com.udayan.oca;
  3. import java.time.LocalDate;
  4. public class Test {
  5. public static void main(String [] args) {
  6. LocalDate date = LocalDate.of(2020, 9, 6);
  7. System.out.println(date);
  8. }
  9. }

What will be the result of compiling and executing Test class?

 

13 / 15

What will be the result of compiling and executing Test class?

  1. package com.udayan.oca;
  2. import java.util.function.Predicate;
  3. public class Test {
  4. public static void main(String[] args) {
  5.         printNumbers(i -> i % 2 != 0);
  6. }
  7. private static void printNumbers(Predicate<Integer> predicate) {
  8. for(int i = 1; i <= 10; i++) {
  9. if(predicate.test(i)) {
  10. System.out.print(i);
  11. }
  12. }
  13. }
  14. }

 

14 / 15

What will be the result of compiling and executing Test class?

  1. package com.udayan.oca;
  2.  
  3. public class Test {
  4.     public static void main(String[] args) {
  5.         String str = "Good"; //Line 3
  6.         change(str); //Line 4
  7.         System.out.println(str); //Line 5
  8.     }
  9.     private static void change(String s) {
  10.         s.concat("_Morning"); //Line 9
  11.     }
  12. }

 

15 / 15

Given code:

  1. package com.udayan.oca;
  2. public class Test {
  3. public static void main(String[] args) {
  4. StringBuilder sb = new StringBuilder(5);
  5. sb.append("0123456789");
  6. sb.delete(8, 1000);
  7. System.out.println(sb);
  8. }
  9. }

What is the result?

 

Your score is

The average score is 53%

0%

Would you like to start an Exam with us?​

Prepare, Practice, and Excel – Your One-Stop Solution for IT Mock Exams Designed to Mirror Real-World Challenges, Enhance Your Expertise, and Propel Your Career to New Heights!