SCJP Quiz | OCJP Quiz | OCJP Online Test Series 1 | Java Online Test
Finish Quiz
0 of 20 questions completed
Questions:
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
Information
SCJP Quiz | OCJP Quiz | OCJP Online Test Series 1 | Java Online Test. Take free Java OCJP/SCJP Quiz 1 and Test your fundamentals with us. Free Java OOPs Quiz, Online Java, online Test Quiz 1. Java OCJP/SCJP Quiz 1 Question and Answers 2019. Java online Test Quiz 1. Java OOPs Quiz 1 Free Mock Test 2019. Java OCJP/SCJP Quiz 1 Question and Answers in PDF. The Java online mock test paper is free for all students. Spring Online is very useful for exam preparation and getting for Rank. Java OCJP/SCJP Quiz 1 Question and Answers in English. Java OOPs Mock test for topic via OOPs Mode. Here we are providing Java OCJP/SCJP Quiz in English Now Test your self for “OCJP/SCJP Online Quiz in English” Exam by using below quiz…
This paper has 20 questions.
Time allowed is 25 minutes.
The Java OOPs Mock Test is Very helpful for all students. Now Scroll down below n click on “Start Quiz” or “Start Test” and Test yourself.
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading...
You must sign in or sign up to start the quiz.
You have to finish following quiz, to start this quiz:
Results
0 of 20 questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 points, (0)
Average score |
|
Your score |
|
Categories
- Not categorized 0%
Pos. | Name | Entered on | Points | Result |
---|---|---|---|---|
Table is loading | ||||
No data available | ||||
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- Answered
- Review
-
Question 1 of 20
1. Question
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 one, independently, will allow Sub to compile?
Correct
Incorrect
-
Question 2 of 20
2. Question
Given:
7. void waitForSignal() {
8. Object obj = new Object();
9. synchronized (Thread.currentThread()) {
10. obj.wait();
11. obj.notify();
12. }
13. }
Which statement is true?Correct
Incorrect
-
Question 3 of 20
3. Question
public class Rainbow {
public enum MyColor {
RED(0xff0000), GREEN(0x00ff00), BLUE(0x0000ff);
private final int rgb;
MyColor(int rgb) { this.rgb = rgb; }
public int getRGB() { return rgb; }
};
public static void main(String[] args) {
// insert code here
}
}
Which code fragment, inserted at line 19, allows the Rainbow class to compile?Correct
Incorrect
-
Question 4 of 20
4. Question
public abstract class Shape {
private int x;
private int y;
public abstract void draw();
public void setAnchor(int x, int y) {
this.x = x;
this.y = y;
}
}Which one class use the Shape class correctly?
Correct
Incorrect
-
Question 5 of 20
5. Question
public class Threads4 {
public static void main (String[] args) {
new Threads4().go();
}
public void go() {
Runnable r = new Runnable() {
public void run() {
System.out.print(“foo”);
}
};
Thread t = new Thread(r);
t.start();}
}Correct
Incorrect
-
Question 6 of 20
6. Question
public class Barn {
public static void main(String[] args) {
new Barn().go(“hi”, 1);
new Barn().go(“hi”, “world”, 2);
}
public void go(String… y, int x) {
System.out.print(y[y.length – 1] + ” “);
}
}What is the result?
Correct
Incorrect
-
Question 7 of 20
7. Question
class PingPong2 {
synchronized void hit(long n) {
for(int i = 1; iCorrect
Incorrect
-
Question 8 of 20
8. Question
interface TestA { String toString(); }
public class Test {
public static void main(String[] args) {
System.out.println(new TestA() {
public String toString() { return “test”; }
});
}
}
What is the result?Correct
Incorrect
-
Question 9 of 20
9. Question
1. public class Threads2 implements Runnable {
2.
3. public void run() {
4. System.out.println(“run.”);
5. throw new RuntimeException(“Problem”);
6. }
7. public static void main(String[] args) {
8. Thread t = new Thread(new Threads2());
9. t.start();
10. System.out.println(“End of method.”);
11. }
12. }
Which one can be result?Correct
Incorrect
-
Question 10 of 20
10. Question
Given:
1. package test;
2.
3. class Target {
4. public String name = “hello”;
5. }What can directly access and change the value of the variable name?
Correct
Incorrect
-
Question 11 of 20
11. Question
Which Man class properly represents the relationship “Man has a best friend
who is a Dog”?Correct
Incorrect
-
Question 12 of 20
12. Question
class Nav{
public enum Direction { NORTH, SOUTH, EAST, WEST }
}
public class Sprite{
// insert code here
}Which code, inserted at line 14, allows the Sprite class to compile?
Correct
Incorrect
-
Question 13 of 20
13. Question
class A{
public static void parse(String str) {
try {
float f = Float.parseFloat(str);
} catch (NumberFormatException nfe) {
f = 0;
} finally {
System.out.println(f);
}
}
public static void main(String[] args) {
parse(“invalid”);
}
}What is the result?
Correct
Incorrect
-
Question 14 of 20
14. Question
class Mud {
public static void main(String…[] a) {// insert code here
System.out.println(“hi”);
}
}
And the following five fragments:
public static void main(String…a) {
public static void main(String.* a) {
public static void main(String… a) {
public static void main(String[]… a) {
public static void main(String…[] a) {
How many of the code fragments, inserted independently at line 12, compile?Correct
Incorrect
-
Question 15 of 20
15. Question
class Atom {
Atom() { System.out.print(“atom “); }
}
class Rock extends Atom {
Rock(String type) { System.out.print(type); }
}
public class Mountain extends Rock {
Mountain() {
super(“granite “);
new Rock(“granite “);
}
public static void main(String[] a) { new Mountain(); }
}What is the result?
Correct
Incorrect
-
Question 16 of 20
16. Question
class Building { }
public class Barn extends Building {
public static void main(String[] args) {
Building build1 = new Building();
Barn barn1 = new Barn();
Barn barn2 = (Barn) build1;
Object obj1 = (Object) build1;
String str1 = (String) build1;
Building build2 = (Building) barn1;
}
}Which is true?
Correct
Incorrect
-
Question 17 of 20
17. Question
Given:
public void go() {
String o = “”;
z:
for(int x = 0; xCorrect
Incorrect
-
Question 18 of 20
18. Question
Which capability exists only in java.io.FileWriter?
Correct
Incorrect
-
Question 19 of 20
19. Question
Given that the current directory is empty, and that the user has read and write permissions, and
the following:
import java.io.*;
public class DOS {
public static void main(String[] args) {
File dir = new File(“dir”);
dir.mkdir();
File f1 = new File(dir, “f1.txt”);
try {
f1.createNewFile();
} catch (IOException e) { ; }
File newDir = new File(“newDir”);
dir.renameTo(newDir);
}
}Which statement is true?
Correct
Incorrect
-
Question 20 of 20
20. Question
Assuming that the serializeBanana() and the deserializeBanana() methods will correctly use Java
serialization and given:import java.io.*;
class Food implements Serializable {int good = 3;}
class Fruit extends Food {int juice = 5;}
public class Banana extends Fruit {
int yellow = 4;
public static void main(String [] args) {
Banana b = new Banana(); Banana b2 = new Banana();
b.serializeBanana(b); // assume correct serialization
b2 = b.deserializeBanana(); // assume correct
System.out.println(“restore “+b2.yellow+ b2.juice+b2.good);
}
// more Banana methods go here
}What is the result?
Correct
Incorrect