Java SE 8 Programmer I exam (1Z0 | 808) Certification
Duration 120 minutes,
Format: Multiple Choice
Number of Questions: 56
Passing Score: 65%
Questions from 29 to 42
Select the most appropriate answer.
public class MainClass{
public static void go(int n) {System.out.pritnln(“int ”);}
public static void go(char n) {System.out.pritnln(“char ”);}
public static void go(bool n) {System.out.pritnln(“bool ”);}
public static void main(String [ ] args) {
char y = 6;
int z = 7;
go(y);
go(z);
}
}
What is the Result?
Option a: char int.
Option b: bool int.
Option c: Compilation Fails.
Option d: An exception is throne at runtime.
Option a: char int.
Select the most appropriate answer.
Which instantiation creates the tightest coupling?
Option a: BioFuel b1 = new BioFuel();
Option b: BioFuel b2 = new BioFuel(new String("canola"))
Option c: BioFuel b3 = new BioFuel(new Integer(42)).
Option d: BioFuel b4 = new BioFuel(new Viscosity()).
Option d: BioFuel b4 = new BioFuel(new Viscosity()).
Select the most appropriate answer.
Which is the result?
Given:
package demoPackage;
class Smooth { }
public class Demo extends Smooth {
int x = 5;
int y = 7;
void go() {
if(x > y & (Boolean)(this instanceof Demo)) System.out.print("a");
if(this instanceof Smooth) System.out.print("b");
}
public static void main(String[] args) {
Demo s = new Demo(); s.go();
}
}
Option a: a
Option b: b
Option c: ab
Option d: Compilation fails.
Option e: An exception is thrown at runtime.
Option b: b
Select all correct answers.
Given:
1. import java.util.*;
2. public class Demo {
3. static class Othello implements Comparator {
4. public int compare(Object a, Object b) {
5. return ((String) b).compareTo((String) a);
6. }
7. }
8. public static void main(String[] args) {
9. String[] s = {"map", "pen", "marble", "key"};
10. Othello o = new Othello();
11. Arrays.sort(s,o);
12. for(String s2: s) System.out.print(s2 + " ");
13. System.out.println(Arrays.binarySearch(s, "map"));
14. }
15. }
Which are incorrect?
Option a: The output will contain a 1
Option b: The output will contain a 2
Option c: The output will contain a – 1
Option d: The output will contain "key map marble pen"
Option e: The output will contain "pen marble map key"
Option a: The output will contain a 1
Option b: The output will contain a 2
Option d: The output will contain "key map marble pen"
Select the most appropriate answer.
Given:
1. class MySuper {
2. public MySuper(int i) {
3. System.out println("super " + i);
4. }
5. }
6.
7. public class MySub extends MySuper {
8. public MySub() {
9. super(4);
10. System.out.println("sub");
11. }
12.
13. public static void main(String [] args) {
14. MySuper sup = new MySub();
15. }
16. }
What is the result?
Option a: sub super 4
Option b: super 4 sub
Option c: Compilation fails at line 8.
Option d: Compilation fails at line 9.
Option e: Compilation fails at line 14.
Option b: super 4 sub
Select the most appropriate answer.
Given Math.random():
import java.lang.Math;
public class Demo {
static int calculateJuice(int seed) {
return (seed * (int)(Math.random() * 1024));
}
public static void main(String [] args) {
System.out. println(calculateJuice(99));
}
}
What is the result?
Option a: The program outputs the value 0.
Option b: The program outputs the value 1.
Option c: The program outputs a value between 0 and 1024.
Option d: The program outputs a value between 0 and 1023
Option e: None of the above.
Option e: None of the above.
Select all correct answers.
Which are incorrect?
Option a: Has-a relationships are, by definition, well encapsulated.
Option b: A covariant return requires the existence of a has-a relationship
Option c: Overriding requires the existence of a is-a relationship
Option d: In some cases, is-a relationships are used in the process of autoboxing
Option e: Has-a relationships are always defined with instance variables
Option a: Has-a relationships are, by definition, well encapsulated.
Option b: A covariant return requires the existence of a has-a relationship
Option e: Has-a relationships are always defined with instance variables
Select the most appropriate answer.
Given:
class Battery {
static int x = 1;
public static void main(String[] args) throws Throwable {
try {
System.out. print("try ");
} catch (Exception e) {
System. out.print("exc ");
} finally {
System.out. print("fin ");
}
}
}
What is the result?
Option a: try
Option b: try fin
Option c: exc fin
Option d: fin Then a runtime exception
Option e: exc fin Then a runtime exception
Option f: Compilation fails
Option b: try fin
Select all correct answers.
Given:
1. interface Face1 {
2. int m1(int a 1);
3. }
4. interface Face2 [
5. int m2(int a2);
6. }
7.
8.
Which code fragments inserted at lines 7 and 8 will not compile?
Option a: class Concrete2 extends Face1 { public int m3(int r); }
Option b: interface Concrete2 implements Face1 { public int m1(int y) { return 7; } }
Option c: class Concrete2 implements Face2 { public int m2(int l) { return 7; } }
Option d: class Concrete2 implements Face2 { public int m1(int r) { return 7; } }
Option e: abstract class Concrete2 implements Face2, Face1 { public int m4() { return 7; } }
Option a: class Concrete2 extends Face1 { public int m3(int r); }
Option b: interface Concrete2 implements Face1 { public int m1(int y) { return 7; } }
Option d: class Concrete2 implements Face2 { public int m1(int r) { return 7; } }
Select all correct answers.
Given:
import java.util .* ;
class Apple { }\n class Macintosh extends Apple {
public static void main(String[] munch) {
List a = new ArrayList();
basket(a);
}
// insert code here
}
Which inserted at // insert code here will not compile?
Option a: static void basket(List list) {list add(new Object()); }
Option b: static void basket(ListOption c: static void basket(List list) {list add(new Object()); }
Option c: static void basket(List list) {list add(new Apple()); }
Option d: static void basket(List list) {list.add(new Apple()): }
Option e: static void basket(List list) {list_size(); }
Option a: static void basket(List list) {list add(new Object()); }
Option c: static void basket(List list) {list add(new Apple()); }
Option d: static void basket(List list) {list.add(new Apple()): }
Select the most appropriate answer.
Given:
1. public class Test {
2. public static int y;
3. public static int foo(int x) {
4. System.out print("foo ");
5. return y = x;
6. }
7. public static int bar(int z) {
8. System. out print("bar ");
9. return y = z;
10. }
11. public static void main(String [] args ) {
12. int t = 2;
13. assert t < 4 : bar(7);
14. assert t ~ 1 : foo(8);
15. System.out. println("done ");
16. }
17. }
What is the result?
Option a: done
Option b: bar done
Option c: foo done
Option d: bar foo done
Option e: Compilation fails.
Option f: An AssertionError is thrown at runtime
Option e: Compilation fails.
Select the most appropriate answer.
In order to cause the paint(Graphics) method to execute, which of the following is the most appropriate method to call:
Option a: paint()
Option b: repaint()
Option c: paint(Graphics)
Option d: update(Graphics)
Option e: None – you should never cause paint(Graphics) to execute
Option b: repaint()
Select all correct answers.
Given a class House, which are incorrect?
Option a: House has-a Roof would be considered tight coupling.
Option b: A turnOnStereo() method would NOT be considered cohesive.
Option c: House is-a Dwelling would be considered good encapsulation.
Option d: House has-a Door would be considered low coupling.
Option e: A getAddress() method would NOT be considered cohesive.
Option a: House has-a Roof would be considered tight coupling.
Option c: House is-a Dwelling would be considered good encapsulation.
Option e: A getAddress() method would NOT be considered cohesive.
Select the most appropriate answer.
What is the result?
1. package demoPackage;
2. public class Demo {
3. public static void main (String args []) {
4. String p = null;
5. p += " Add ";
6. System.out.print(p);
7. p = null;
8. p = p +" Add " ;
9. System.out.print(p);
10. }
11. }
Option a: null Add null Add
Option b: Add null Add null
Option c: null null
Option d: Add Add
Option e: Compile error on Line 5
Option f: Compile error on Line 8
Option g: No output after compiling.
Option a: null Add null Add
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.
Made with
Landing Page Software