OCJP Quiz | SCJP Quiz | OCJP Online Test Series 3 | 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 Quiz | SCJP Quiz | OCJP Online Test Series 3 | Java Online Test. Take Free Java OOPs Quiz and Test your fundamentals. This Online Java test is free for all users. online Test Quiz 3. Java OCJP/SCJP Quiz 3 Question and Answers 2019. Java online Test Quiz 3. Java OOPs Quiz 3 Free Mock Test 2019. Java OCJP/SCJP Quiz 3 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 3 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
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 2 of 20
2. Question
package com.company.application;
public class MainClass {
public static void main(String[] args) {}
}And MainClass exists in the /apps/com/company/application directory. Assume the CLASSPATH
environment variable is set to “.” (current directory).
Which one java command entered at the command line will run MainClass?Correct
Incorrect
-
Question 3 of 20
3. Question
interface Foo {}
class Alpha implements Foo {}
class Beta extends Alpha {}
class Delta extends Beta {
public static void main( String[] args ) {
Beta x = new Beta();
// insert code here
}
}Which code, inserted at line 16, will cause a java.lang.ClassCastException?
Which code, inserted at line 16, will cause a java.lang.ClassCastException?
Correct
Incorrect
-
Question 4 of 20
4. 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 5 of 20
5. Question
Which one statements is true about the hashCode method?
Correct
Incorrect
-
Question 6 of 20
6. Question
A company has a business application that provides its users with many different reports: receivables reports, payables reports, revenue projects, and so on. The company has just purchased some new, state-of-the-art, wireless printers, and a programmer has been assigned the task of enhancing all of the reports to use not only the company’s old printers, but the new wireless printers as well. When the programmer starts looking into the application, the programmer discovers that because of the design of the application, it is necessary to make changes to each report to support the new printers. Which one design concepts most likely explain this situation?
Correct
Incorrect
-
Question 7 of 20
7. Question
public class Test {
public static void main(String [] args) {
for(int x = 1; x System.out.print(args[x] + ” “);
}
}
}and two separate command line invocations:
java Yippee
java Yippee 1 2 3 4
What is the result?Correct
Incorrect
-
Question 8 of 20
8. Question
A company that makes Computer Assisted Design (CAD) software has, within its application, some utility classes that are used to perform 3D rendering tasks. The company’s chief scientist has just improved the performance of one of the utility classes’ key rendering algorithms, and has assigned a programmer to replace the old algorithm with the new algorithm. When the programmer begins researching the utility classes, she is happy to discover that the algorithm to be replaced exists in only one class. The programmer reviews that class’s API, and replaces the old algorithm with the new algorithm, being careful that her changes adhere strictly to the class’s API. Once testing has begun, the programmer discovers that other classes that use the class she changed are no longer working properly. What design flaw is most likely the cause of these new bugs?
Correct
Incorrect
-
Question 9 of 20
9. Question
class Foo {
public int a = 3;
public void addFive() { a += 5; System.out.print(“f “); }
}
class Bar extends Foo {
public int a = 8;
public void addFive() { this.a += 5; System.out.print(“b ” ); }public static void main(String args[]){
Foo f = new Bar();
f.addFive();
System.out.println(f.a);}
}
What is the result?
Correct
Incorrect
-
Question 10 of 20
10. Question
Given a pre-generics implementation of a method:
public static int sum(List list) {
int sum = 0;
for ( Iterator iter = list.iterator(); iter.hasNext(); ) {
int i = ((Integer)iter.next()).intValue();
sum += i;
}
return sum;
}Which one changes must be made to the method sum to use generics?
Correct
Incorrect
-
Question 11 of 20
11. Question
import java.util.*;
public class WrappedString {
private String s;
public WrappedString(String s) { this.s = s; }
public static void main(String[] args) {
HashSetWhat is the result?
Correct
Incorrect
-
Question 12 of 20
12. Question
public class Tea {
public static void main(String [] args) {
int x = 5;
Tea t = new Tea();
t.doStuff(x);
System.out.print(” main x = ” + x);
}void doStuff(int x) {
System.out.print(” doStuff x = ” + x++);
}
}What is the result?
Correct
Incorrect
-
Question 13 of 20
13. Question
// insert code here
private N min, max;
public N getMin() { return min; }
public N getMax() { return max; }
public void add(N added) {
if (min == null || added.doubleValue() max.doubleValue())
max = added;
}
}
Which one, inserted at line 11, will allow the code to compile?Correct
Incorrect
-
Question 14 of 20
14. Question
import java.util.*;
public class GetInLine {
public static void main(String[] args) {
PriorityQueue pq = new PriorityQueue();
pq.add(“banana”);
pq.add(“pear”);
pq.add(“apple”);
System.out.println(pq.poll() + ” ” + pq.peek());
}
}What is the result?
Correct
Incorrect
-
Question 15 of 20
15. Question
class SuperCalc {
protected static int multiply(int a, int b) { return a * b;}
}public class SubCalc extends SuperCalc{
public static int multiply(int a, int b) {
int c = super.multiply(a, b);
return c;
}public static void main(String args[]){
SubCalc sc = new SubCalc ();
System.out.println(sc.multiply(3,4));
System.out.println(SubCalc.multiply(2,2));}
}
What is the result?
Correct
Incorrect
-
Question 16 of 20
16. Question
class Thingy { Meter m = new Meter(); }
class Component { void go() { System.out.print(“c”); } }
class Meter extends Component { void go() { System.out.print(“m”); } }class DeluxeThingy extends Thingy {
public static void main(String[] args) {
DeluxeThingy dt = new DeluxeThingy();
dt.m.go();
Thingy t = new DeluxeThingy();
t.m.go();
}
}Which one is true?
Correct
Incorrect
-
Question 17 of 20
17. Question
import java.util.*;
public class Mapit {
public static void main(String[] args) {
Set set = new HashSet();
Integer i1 = 45;
Integer i2 = 46;
set.add(i1);
set.add(i1);
set.add(i2); System.out.print(set.size() + ” “);
set.remove(i1); System.out.print(set.size() + ” “);
i2 = 47;
set.remove(i2); System.out.print(set.size() + ” “);
}
}What is the result?
Correct
Incorrect
-
Question 18 of 20
18. Question
class ClassA {
public int numberOfInstances;
protected ClassA(int numberOfInstances) {
this.numberOfInstances = numberOfInstances;
}
}
public class ExtendedA extends ClassA {
private ExtendedA(int numberOfInstances) {
super(numberOfInstances);
}
public static void main(String[] args) {
ExtendedA ext = new ExtendedA(420);
System.out.print(ext.numberOfInstances);
}
}Which statement is true?
Correct
Incorrect
-
Question 19 of 20
19. Question
public class Bat {
int squares = 81;
public static void main(String[] args) {
new Bat().go();
}
void go() {
incr(++squares);
System.out.println(squares);
}
void incr(int squares) { squares += 10; }
}What is the result?
Correct
Incorrect
-
Question 20 of 20
20. Question
interface Animal { void makeNoise(); }
class Horse implements Animal {
Long weight = 1200L;
public void makeNoise() { System.out.println(“whinny”); }
}
public class Icelandic extends Horse {
public void makeNoise() { System.out.println(“vinny”); }
public static void main(String[] args) {
Icelandic i1 = new Icelandic();
Icelandic i2 = new Icelandic();
Icelandic i3 = new Icelandic();
i3 = i1; i1 = i2; i2 = null; i3 = i1;
}
}When line 14 is reached, how many objects are eligible for the garbage collector?
Correct
Incorrect