Dd2

45 Questions | Attempts: 800
Share
Please wait...
Question 1 / 45
0 %
0/100
Score 0/100
1. Consider the following code snippet:   abstract class Director { protected String name;   Director(String name) { this.name = name; } abstract void occupation(); }   class FilmDirector extends Director { FilmDirector(String name) { super(name); }   void occupation() { System.out.println("Director " + name + " directs films"); } }   public class TestDirector { public static void main(String[] args) { FilmDirector fd = new FilmDirector("Manirathnam"); fd.occupation(); new Director("Manirathnam") { void occupation() { System.out.println("Director " + name + " also produces films"); } }.occupation(); } }   Which of the following will be the output of the above code snippet?  
Submit
Please wait...
About This Quiz
Dd2 - Quiz

Tell us your name to personalize your report, certificate & get on the leaderboard!
2. Consider the following code snippet:   class TestString2 { public static void main(String args[]) { String s1 = "Test1"; String s2 = "Test2";   s1.concat(s2);   System.out.println(""+s1.charAt(s1.length() - 3) + s1.indexOf(s2)); } }   What will be the output of the above code snippet?
Submit
3. Consider the following program:   public class Exp4 { static String s = "smile!.."; public static void main(String[] args) { new Exp4().s1(); System.out.println(s); }   void s1() { try { s2();   } catch (Exception e) { s += "morning"; } }   void s2() throws Exception { s3(); s += "evening"; s3(); s += "good"; }   void s3() throws Exception { throw new Exception(); } }   What will be the output of the above program?
Submit
4. Consider the following code:   class One { public One() {   System.out.print(1); } } class Two extends One { public Two() { System.out.print(2); } } class Three extends Two { public Three() { System.out.print(3); } } public class Numbers { public static void main(String[] argv) { new Three(); } } Which of the following will be the output for the above program?
Submit
5. Which of the following options gives the difference between == operator and equals() method?
Submit
6. Consider the following program:   class A implements Runnable { public void run() { System.out.print(Thread.currentThread().getName()); } }   class B implements Runnable { public void run() { new A().run(); new Thread(new A(),"T2").run(); new Thread(new A(),"T3").start(); } }   class C { public static void main (String[] args) { new Thread(new B(),"T1").start(); } }   What will be the output of the above program?
Submit
7. Which of the following gives the set of Annotations declared in java.lang package?
Submit
8. Consider the following code:   class ExampleFive { public static void main(String[] args) { final int i = 22; byte b = i; System.out.println(i + ", " + b); } }   Which of the following gives the valid output for the above code?
Submit
9. Which of the following are true about inheritance?(Choose 3)
Submit
10. Which of the following options gives the relationship between a Spreadsheet Object and Cell Objects?
Submit
11. Consider the following program:   public class D extends Thread { public void run() { System.out.println("Before start method"); this.stop(); System.out.println("After stop method"); }   public static void main(String[] args) { D a = new D(); a.start(); } }   What will be the output of the above program?
Submit
12. Consider the following scenario:   A Java application needs to stream a video from a movie file.   Which of the following options gives the correct combination of stream classes that can be used to implement the above requirement?
Submit
13. Which of the following is the best-performing implementation of Set interface?
Submit
14. Which of the following are correct regarding HashCode?(Choose 2)
Submit
15. Which of the following class in java.sql package maps the SQL data types to Java datatypes?
Submit
16. Consider the following code snippet:   public class Welcome { String title; int value;   public Welcome() { title += " Planet"; }   public void Welcome() { System.out.println(title + " " + value); }   public Welcome(int value) { this.value = value; title = "Welcome"; Welcome(); }   public static void main(String args[]) { Welcome t = new Welcome(5); } }   Which of the following option will be the output for the above code snippet?
Submit
17. Which of the following ways can be used to access the String value in the first column of a ResultSet? (Assume rs is the ResultSet object)
Submit
18. A monitor called 'mon' has 5 threads in its waiting pool; all these waiting threads have the same priority. One of the threads is thread1. How can you notify thread1 so that it alone moves from Waiting state to Ready State?
Submit
19. Consider the following code:   public class Choco { Choco() { System.out.print("Choco"); }   class Bar { Bar() { System.out.print("bar"); } public void go() { System.out.print("sweet"); } }   public static void main(String[] args) { Choco c = new Choco(); c.makeBar(); } void makeBar(){ // Insert code here } }   Which of the following code snippet when substituted individually to the above commented line (// Insert code here) will give the following output?   Chocobarsweet
Submit
20. Consider the following code snippet:   class Lock1 { Lock1() { } Lock1(Lock2 lock2) { this.lock2 = lock2; } Lock2 lock2; }   class Lock2 { Lock2() { } Lock2(Lock1 lock1) { this.lock1 = lock1; } Lock1 lock1; }   class GC6 { public static void main(String args[]) { Lock1 l1 = new Lock1(); Lock2 l2 = new Lock2(l1); l1.lock2 = l2; } }   Which of the objects are eligible for garbage collection in the above code?
Submit
21. To which of the following elements, annotations can be applied? (Choose 3)
Submit
22. Which of the following is true about finalize() method?
Submit
23. Which of the following options will protect the underlying collections from getting modified?
Submit
24. Which of the following options give the names of data structures that can be used for elements that have ordering, but no duplicates? (Choose 2)
Submit
25. Consider the following code:   package test;   class Target { String name = "hello"; }   Which of the following options are valid that can directly access and change the value of the variable 'name' in the above code? (Choose 2)
Submit
26. Which of the following classes is new to JDK 1.6?
Submit
27. Consider the following code snippet:   class Train { String name = "Shatapdhi"; }   class TestTrain { public static void main(String a[]) { Train t = new Train(); System.out.println(t); // Line a System.out.println(t.toString()); // Line b } }   Which of the following statements are true?(Choose 3)
Submit
28. Consider the following code:   1. public class SwitchIt { 2. public static void main(String[] args) { 3. int w1 = 1; 4. int w2 = 2; 5. System.out.println(getW1W2(w1, w2)); 6. } 7. 8. public static int getW1W2(int x, int y) { 9. switch (x) { 10. case 1: x = x + y; 11. case 2: x = x + y; 12. }   13. return x; 14. } 15. } Which of the following gives the valid output of above code?
Submit
29. You need to create a class that implements the Runnable interface to do background image processing. Out of the following list of method declarations, select the method that must satisfy the requirements.
Submit
30. The return value of execute() method in Statement interface is __________________.
Submit
31. Consider the following code:   public class SwitchIt { public static void main(String args[]) { int x = 10;   switch(x) { case 10: for(int i=0; i break;   case 20: System.out.println(x); break;   case 30: System.out.println(x*2); break;   default: System.out.println(x*3); } } }   Which of the following will be the output for the above program?
Submit
32. Which of the following are the valid ways of conversion from Wrapper type to primitive type? (Choose 3)
Submit
33. Consider the following scenario:   Here is part of the hierarchy of exceptions that may be thrown during file IO operations:   Exception +-IOException +-File Not Found Exception   You have a method X that is supposed to open a file by name and read data from it. Given that X does not have any try-catch statements, which of the following option is true?
Submit
34. At which of the following given situations, unit tests are required to be run on the modules?(Choose 3)
Submit
35. Consider the following code:   1 public class A { 2 public void m1() {System.out.print("A.m1, ");} 3 protected void m2() {System.out.print("A.m2, ");} 4 private void m3() {System.out.print("A.m3, ");} 5 void m4() {System.out.print("A.m4, ");} 6 7 public static void main(String[] args) { 8 A a = new A(); 9 a.m1(); 10 a.m2(); 11 a.m3(); 12 a.m4(); 13 } 14 }   Which of the following gives the lines that need to be removed in order to compile and run the above code correctly?
Submit
36. Which of the following statements are correct regarding Static Blocks?(Choose 3)
Submit
37. Consider the following code snippet:   interface i1 { int i = 0; }   interface i2 { int i = 0; }   class inter implements i1, i2 { public static void main(String[] a) { System.out.println(i); } }   Which of the following options will be the output of the above code snippet?
Submit
38. Consider the following program:   public class TryIt { public static void main(String args[]) { try { int i = 0; try { i = 100 / i; } catch(Error e) { System.out.println("Divide by Zero error"); } System.out.println("Error Handled"); } catch(Exception e) { System.out.println("Unexpected exception caught"); } } }   What will be the output of the above program?
Submit
39. Consider the following code:   class A { } class B extends A { } public class Code2 { public void method(A a) {   System.out.println("A"); } public void method(B b) { System.out.println("B"); } public static void main(String args[]) { new Code2().method(new Object()); } } Which of the following will be the output for the above code?
Submit
40. Consider the following code:   1. class ExampleSix { 2. String msg = "Type is "; 3. public void showType(int n) { 4. String tmp; 5. if(n > 0) tmp = "positive"; 6. System.out.println(msg + tmp); 7. } 8. }   On running the above code it throws the compile-time error- the variable tmp is not initialised.   Which of the following changes to the above code will make the code to compile properly? (Choose 3)
Submit
41. Which of the following actions include the external library required by Java application at runtime in order to run properly? (choose 2)
Submit
42. Consider the following code snippet:   import java.io.*;   class Student { private String studentID; private String studentName;   public Student() { } public Student(String studentID, String studentName) { this.studentID = studentID; this.studentName = studentName; }   public String toString() { return "Student ID : " + studentID + " " + "Student Name : " + studentName; } }   public class IOCode3 { public static void main(String args[]) throws FileNotFoundException, IOException { ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("C:/ObjectData")); // Line 1 out.writeObject(new Student("100", "Student One")); // Line 2 out.close();   } }   What will be the output of the above code snippet?
Submit
43. Consider the following program:   class RE { public static void main(String args[]) { try { String s = null; System.out.println(s.length()); } catch(NullPointerException npe) { System.out.println("NullPointerException handled"); throw new Exception(npe.getMessage()); } } }   What will be the output of the above program?
Submit
44. Consider the following code snippet:   class Student { String studentID; String studentName; double score; }   The instances of the above defined class holds the information of individual   student. These details needs to be maintained in a data structure, that   * allows searching of student details using studentID * ascending order of Student objects based on studentID   Which of the following collection classes can be used to implement the above scenario?
Submit
45. Consider the following code:   class ABC { public void method1() { DEF def = new DEF(); def.method2(); } }   class DEF { public XYZ xyz;   public String method2() { return xyz.method3(); } }   class XYZ { public String value;   public String method3() { value = "XYZ"; return value; } }   class TestCode { public static void main(String args[]) { ABC abc = new ABC(); abc.method1(); } }   Which of the following will be the output if the above code is compiled and executed?
Submit
View My Results

Quiz Review Timeline (Updated): Jul 30, 2011 +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Jul 30, 2011
    Quiz Edited by
    ProProfs Editorial Team
  • Apr 26, 2011
    Quiz Created by
    Unrealvicky
Cancel
  • All
    All (45)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
Consider the following code snippet:...
Consider the following code snippet:...
Consider the following program:...
Consider the following code:...
Which of the following options gives the difference between ==...
Consider the following program:...
Which of the following gives the set of Annotations declared in...
Consider the following code:...
Which of the following are true about inheritance?(Choose 3)
Which of the following options gives the relationship between a...
Consider the following program:...
Consider the following scenario:...
Which of the following is the best-performing implementation of Set...
Which of the following are correct regarding HashCode?(Choose 2)
Which of the following class in java.sql package maps the SQL data...
Consider the following code snippet:...
Which of the following ways can be used to access the String value in...
A monitor called 'mon' has 5 threads in its waiting pool; all...
Consider the following code:...
Consider the following code snippet:...
To which of the following elements, annotations can be applied?...
Which of the following is true about finalize() method?
Which of the following options will protect the underlying collections...
Which of the following options give the names of data structures that...
Consider the following code:...
Which of the following classes is new to JDK 1.6?
Consider the following code snippet:...
Consider the following code:...
You need to create a class that implements the Runnable interface to...
The return value of execute() method in Statement interface is...
Consider the following code:...
Which of the following are the valid ways of conversion from Wrapper...
Consider the following scenario:...
At which of the following given situations, unit tests are required to...
Consider the following code:...
Which of the following statements are correct regarding Static...
Consider the following code snippet:...
Consider the following program:...
Consider the following code:...
Consider the following code:...
Which of the following actions include the external library required...
Consider the following code snippet:...
Consider the following program:...
Consider the following code snippet:...
Consider the following code:...
Alert!

Advertisement