OCJP Online Test Series 5 | OCJP Quiz | SCJP Quiz | 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
OCJP Online Test Series 5 | OCJP Quiz | SCJP Quiz | Java Online Test. Now take Free Java OOPs Quiz and test your study easily via online mode. This Free Online Java is very useful for technical interviews. online Test Quiz 5. Java OCJP/SCJP Quiz 5 Question and Answers 2024. Java online Test Quiz 5. Java OOPs Quiz 5 Free Mock Test 2024. Java OCJP/SCJP Quiz 5 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 5 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
public interface Status {
/* insert code here */ int MY_VALUE = 10;
}
Which one is valid on line 12?Correct
Incorrect
-
Question 2 of 20
2. Question
Given the following six method names:
addListener
addMouseListener
setMouseListener
deleteMouseListener
removeMouseListener
registerMouseListener
How many of these method names follow JavaBean Listener naming rules?Correct
Incorrect
-
Question 3 of 20
3. Question
public static void test(String str) {
int check = 4;
if (check = str.length()) {
System.out.print(str.charAt(check -= 1) +”, “);
} else {
System.out.print(str.charAt(0) + “, “);
}
}and the invocation:
test(“four”);
test(“tee”);
test(“to”);What is the result?
Correct
Incorrect
-
Question 4 of 20
4. Question
class Line {
public static class Point {}
}class Triangle {
// insert code here
}Which code, inserted at line 15, creates an instance of the Point class defined in Line?
Correct
Incorrect
-
Question 5 of 20
5. Question
package util;
public class BitUtils {
public static void process(byte[] b) { /* more code here */ }
}package app;
public class SomeApp {
public static void main(String[] args) {
byte[] bytes = new byte[256];
// insert code here
}
}What is required at line 5 in class SomeApp to use the process method of BitUtils?
Correct
Incorrect
-
Question 6 of 20
6. Question
public class Test {
public enum Dogs {collie, harrier};
public static void main(String [] args) {
Dogs myDog = Dogs.collie;
switch (myDog) {
case collie:
System.out.print(“collie “);
case harrier:
System.out.print(“harrier “);
}
}
}What is the result?
Correct
Incorrect
-
Question 7 of 20
7. Question
Given:
class Snoochy {
Boochy booch;
public Snoochy() { booch = new Boochy(this); }
}class Boochy {
Snoochy snooch;
public Boochy(Snoochy s) { snooch = s; }
}And the statements:
public static void main(String[] args) {
Snoochy snoog = new Snoochy();
snoog = null;
// more code here
}
Which statement is true about the objects referenced by snoog, snooch, and booch immediately after line
23 executes?Correct
Incorrect
-
Question 8 of 20
8. Question
class Test{
static void test() throws Error {
if (true) throw new AssertionError();
System.out.print(“test “);
}
public static void main(String[] args) {
try { test(); }
catch (Exception ex) { System.out.print(“exception “); }
System.out.print(“end “);
}}
What is the result?
Correct
Incorrect
-
Question 9 of 20
9. Question
class Payload {
private int weight;
public Payload (int w) { weight = w; }
public void setWeight(int w) { weight = w; }
public String toString() { return Integer.toString(weight); }
}
public class TestPayload {
static void changePayload(Payload p) { /* insert code */ }
public static void main(String[] args) {
Payload p = new Payload(200);
p.setWeight(1024);
changePayload(p);
System.out.println(“p is ” + p);
} }Which code fragment, inserted at the end of line 12, produces the output p is 420?
Correct
Incorrect
-
Question 10 of 20
10. Question
public enum Title {
MR(“Mr.”), MRS(“Mrs.”), MS(“Ms.”);
private final String title;
private Title(String t) { title = t; }
public String format(String last, String first) {
return title + ” ” + first + ” ” + last;
}
}
public static void main(String[] args) {
System.out.println(Title.MR.format(“Doe”, “John”));
}What is the result?
Correct
Incorrect
-
Question 11 of 20
11. Question
Given:
11. String test = “Test A. Test B. Test C.”;
12. // insert code here
13. String[] result = test.split(regex);
Which regular expression, inserted at line 12, correctly splits test into “Test A”, “Test B”, and “Test C”?Correct
Incorrect
-
Question 12 of 20
12. Question
public class BuildStuff {
public static void main(String[] args) {
Boolean test = new Boolean(true);
Integer x = 343;
Integer y = new BuildStuff().go(test, x);
System.out.println(y);
}
int go(Boolean b, int i) {
if(b) return (i/7);
return (i/49);
}
}What is the result?
Correct
Incorrect
-
Question 13 of 20
13. Question
import java.util.*;
class Test{public static Collection get() {
Collection sorted = new LinkedList();
sorted.add(“B”); sorted.add(“C”); sorted.add(“A”);
return sorted;
}
public static void main(String[] args) {
for (Object obj: get()) {
System.out.print(obj + “, “);
}
}}
What is the result?
Correct
Incorrect
-
Question 14 of 20
14. Question
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 15 of 20
15. Question
public class TestString3 {
public static void main(String[] args) {
// insert code here
System.out.println(s);
}
}Which two code fragments, inserted independently at line 3, generate the output 4247? (Choose two.)
Correct
Incorrect
-
Question 16 of 20
16. Question
import java.io.*;
public class Talk {
public static void main(String[] args) {
Console c = new Console();
String pw;
System.out.print(“password: “);
pw = c.readLine();
System.out.println(“got ” + pw);
}
}If the user types the password aiko when prompted, what is the result?
Correct
Incorrect
-
Question 17 of 20
17. Question
public class Fo {
static int[] a;
static { a[0]=2; }
public static void main( String[] args ) {}
}Which exception or error will be thrown when a programmer attempts to run this code?
Correct
Incorrect
-
Question 18 of 20
18. Question
public class Base {
public static final String FOO = “foo”;
public static void main(String[] args) {
Base b = new Base();
Sub s = new Sub();
System.out.print(Base.FOO);
System.out.print(Sub.FOO);
System.out.print(b.FOO);
System.out.print(s.FOO);
System.out.print(((Base)s).FOO);
} }
class Sub extends Base {public static final String FOO=”bar”;}What is the result?
Correct
Incorrect
-
Question 19 of 20
19. Question
import java.util.Date;
import java.text.DateFormat;
DateFormat df;
Date date = new Date();
// insert code here
String s = df.format(date);Which code fragment, inserted at line 23, allows the code to compile?
Correct
Incorrect
-
Question 20 of 20
20. Question
Given:
interface A { public void aMethod(); }
interface B { public void bMethod(); }
interface C extends A,B { public void cMethod(); }
class D implements B {
public void bMethod(){}
}
class E extends D implements C {
public void aMethod(){}
public void bMethod(){}
public void cMethod(){}
}What is the result?
Correct
Incorrect