Contact Admin for Dumps and Queries

Just drop a mail to javasnips@gmail.com with subject as "SCJP Dumps" or "SCWCD/SCBCD Dumps".

OCPJP - Test yourself

 If you are interested in OCJP exam suggestions, try these mock question that we will post weekly. Its like a discussion. Post your answers as comments

Question 1:
public class Yikes {
public static void go(Long n) {System.out.println("Long ");}
public static void go(Short n) {System.out.println("Short ");}
public static void go(int n) {System.out.println("int ");}
public static void main(String [] args) {
short y = 6;
long z = 7;
go(y);
go(z);
}
}
What is the result?
A. int Long
B. Short Long
C. Compilation fails.
D. An exception is thrown at run time.

Question 2:
Which two statements are true about has-a and is-a relationships? (Choose
two.)
A. Inheritance represents an is-a relationship.
B. Inheritance represents a has-a relationship.
C. Interfaces must be used when creating a has-a relationship.
D. Instance variables can be used when creating a has-a relationship.
Answer: A, D

Question 3:
public class Hello {
String title;
int value;
public Hello() {
title += " World";
}
public Hello(int value) {
this.value = value;
title = "Hello";
Hello();
}
}
and:
Hello c = new Hello(5);
System.out.println(c.title);
What is the result?
A. Hello
B. Hello World
C. Compilation fails.
D. Hello World 5
E. The code runs with no output.
F. An exception is thrown at runtime.


Question 4:
class Super {
private int a;
protected Super(int a) { this.a = a; }
}
...
class Sub extends Super {
public Sub(int a) { super(a); }
public Sub() { this.a = 5; }
}
which two, independently, will allow Sub to compile? (Choose two.)
A. Change line 2 to:
public int a;
B. Change line 2 to :protected int a;
C. Change line 13 to :public Sub() { this(5); }
D. Change line 13 to :public Sub() { super(5); }
E. Change line 13 to :public Sub() { super(a); }

Visitor Count

hit counter