SCJP Quiz | OCJP Quiz | OCJP Online Test Series 2 | 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 2 | Java Online Test. Now Take Free Java OOPs Quiz and Test your fundamentals with our online Test 2024. Online Java, online Test Quiz 2. Java OCJP/SCJP Quiz 2 Question and Answers 2024. Java online Test Quiz 2. Java OOPs Quiz 2 Free Mock Test 2024. Java OCJP/SCJP Quiz 2 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 2 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
Given:
11. double input = 314159.26;
12. NumberFormat nf = NumberFormat.getInstance(Locale.ITALIAN);
13. String b;
14. //insert code here
Which code, inserted at line 14, sets the value of b to 314.159,26?Correct
Incorrect
-
Question 2 of 20
2. Question
class Money {
private String country = “Canada”;
public String getC() { return country; }
}
class Yen extends Money {
public String getC() { return super.country; }
}
public class Euro extends Money {
public String getC(int x) { return super.getC(); }
public static void main(String[] args) {
System.out.print(new Yen().getC() + ” ” + new Euro().getC());
}
}What is the result?
Correct
Incorrect
-
Question 3 of 20
3. Question
Given:
public class Test {
public static void main(String [] args) {
int x = 5;
boolean b1 = true;
boolean b2 = false;if ((x == 4) && !b2 )
System.out.print(“1 “);
System.out.print(“2 “);
if ((b2 = true) && b1 )
System.out.print(“3 “);
}
}What is the result?
Correct
Incorrect
-
Question 4 of 20
4. Question
Given:
public class LineUp {
public static void main(String[] args) {
double d = 12.345;
// insert code here
}
}Which code fragment, inserted at line 4, produces the output | 12.345|?
Correct
Incorrect
-
Question 5 of 20
5. Question
Given:
class A{
static void test() throws RuntimeException {
try {
System.out.print(“test “);
throw new RuntimeException();
}
catch (Exception ex) { System.out.print(“exception “); }
}
public static void main(String[] args) {
try { test(); }
catch (RuntimeException ex) { System.out.print(“runtime “); }
System.out.print(“end “);
}}
What is the result?
Correct
Incorrect
-
Question 6 of 20
6. Question
Given:
StringBuilder sb1 = new StringBuilder(“123”);
String s1 = “123”;
// insert code here
System.out.println(sb1 + ” ” + s1);Which code fragment, inserted at line 24, outputs “123abc 123abc”?
Correct
Incorrect
-
Question 7 of 20
7. Question
public class TestString1 {
public static void main(String[] args) {
String str = “420”;
str += 42;
System.out.print(str);
}
}What is the output?
Correct
Incorrect
-
Question 8 of 20
8. Question
Given:
interface Foo {}
class Alpha implements Foo {}
class Beta extends Alpha {}
class Delta extends Beta {
public static void main( String[] args ) {
Beta x = new Beta();
Foo f = (Delta)x;// insert code here
}
}Which code, inserted at line 16, will cause a java.lang.ClassCastException?
Correct
Incorrect
-
Question 9 of 20
9. Question
Given:
11. abstract class Vehicle { public int speed() { return 0; }
12. class Car extends Vehicle { public int speed() { return 60; }
13. class RaceCar extends Car { public int speed() { return 150; }
…
21. RaceCar racer = new RaceCar();
22. Car car = new RaceCar();
23. Vehicle vehicle = new RaceCar();
24. System.out.println(racer.speed() + “, ” + car.speed()
25. + “, ” + vehicle.speed());What is the result?
Correct
Incorrect
-
Question 10 of 20
10. Question
A team of programmers is reviewing a proposed API for a new utility class. After some discussion,
they realize that they can reduce the number of methods in the API without losing any
functionality. If they implement the new design, which two OO principles will they be promoting?Correct
Incorrect
-
Question 11 of 20
11. Question
class Test{
public static void main(String args[]){
Object [] myObjects = {
new Integer(12),
new String(“foo”),
new Integer(5),
new Boolean(true)
};
Arrays.sort(myObjects);
for(int i=0; iCorrect
Incorrect
-
Question 12 of 20
12. Question
public class Person {
private String name;
public Person(String name) { this.name = name; }
public boolean equals(Person p) {
return p.name.equals(this.name);
}
}Which statement is true?
Correct
Incorrect
-
Question 13 of 20
13. Question
class A{
public static void main(String args[]){
StringBuilder sb1 = new StringBuilder(“123”);
String s1 = “123”;
sb1.concat(“abc”); s1.append(“abc”);// insert code here
System.out.println(sb1 + ” ” + s1);
}
}Which code fragment, inserted at line 24, outputs “123abc 123abc”?
Correct
Incorrect
-
Question 14 of 20
14. Question
class Test{
static void test() throws RuntimeException {
try {
System.out.print(“test “);
throw new RuntimeException();
}
catch (Exception ex) { System.out.print(“exception “); }
}
public static void main(String[] args) {
try { test(); }
catch (RuntimeException ex) { System.out.print(“runtime “); }
System.out.print(“end “);
}
}What is the result?
Correct
Incorrect
-
Question 15 of 20
15. Question
public class Test{
Integer i;
int x;
public Test(int y) {
x = i+y;
System.out.println(x);
}
public static void main(String[] args) {
new Test(new Integer(4));
}
}What is the result?
Correct
Incorrect
-
Question 16 of 20
16. Question
class Test{
public static void main(String args[]){int x = 0;
int y = 10;
do {
y–;
++x;
} while (x < 5); System.out.print(x + "," + y); } } What is the result?Correct
Incorrect
-
Question 17 of 20
17. Question
class Test{
public static void main(String args[]){try {
// some code here
} catch (NullPointerException e1) {
System.out.print(“a”);
} catch (Exception e2) {
System.out.print(“b”);
} finally {
System.out.print(“c”);
}}
}If some sort of exception is thrown at line 34, which output is possible?
Correct
Incorrect
-
Question 18 of 20
18. Question
class Test{
public void go() {
String o = “”;
z:
for(int x = 0; x < 3; x++) { for(int y = 0; y < 2; y++) { if(x==1) break; if(x==2 && y==1) break z; o = o + x + y; } } System.out.println(o); } public static void main(String args[]){ Test t=new Test(); t.go(); } } What is the result when the go() method is invoked?Correct
Incorrect
-
Question 19 of 20
19. Question
public class Test {
public static void main(String[] args) {
boolean assertsOn = true;
assert (assertsOn) : assertsOn = true;
if(assertsOn) {
System.out.println(“assert is on”);
}
}
}If class Test is invoked twice, the first time without assertions enabled, and the second time with
assertions enabled, what are the results?Correct
Incorrect
-
Question 20 of 20
20. Question
public class Test {
public static void main(String[] args) {
Float pi = new Float(3.14f);
if (pi > 3) {
System.out.print(“pi is bigger than 3. “);
}
else {
System.out.print(“pi is not bigger than 3. “);
}
finally {
System.out.println(“Have a nice day.”);
}}
}What is the result?
Correct
Incorrect