Dd5

45 Questions | Attempts: 573
Please wait...
Question 1 / 46
🏆 Rank #--
Score 0/100

1. Consider s1 and s2 are sets. Which of the following options gives the exact meaning of the method call s1.retainAll(s2)?

Submit
Please wait...
About This Quiz
Dd5 - Quiz

2.

What first name or nickname would you like us to use?

You may optionally provide this to label your report, leaderboard, or certificate.

2. Which of the following is the process of creating a new class from an existing class?

Submit

3. Consider the following code: public class WrapIt { public static void main(String[] args) { new WrapIt().testC('a'); } public void testC(char ch) { Integer ss = new Integer(ch); Character cc = new Character(ch); if(ss.equals(cc)) System.out.print("equals "); if(ss.intValue()==cc.charValue()) { System.out.println("EQ"); } } }  Which of the following gives the valid output for the above code?

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. Consider the following code: 1. public class GetArray2 { 2. public static void main(String [] args) { 3. int [][] holdit = new int[6][]; 4. for(int x = 0;x<6;x++) { 5. holdit[x] = new int[3]; 6. holdit[x][0] = (x + 0); 7. holdit[x][1] = (x + 1); 8. holdit[x][2] = (x + 2); 9. System.out.println(holdit[x][0]+" "+holdit[x][1]+" "+holdit[x][2]); 10. } 11. } 12. } Which of the following gives the valid output for above?

Submit

6. Consider the following code snippet: public class TestString10{ public void print() { String s = "Hello"; StringBuffer sb = new StringBuffer("Hello"); concatinateStrings(s, sb); System.out.println(s+" "+sb); } public void concatinateStrings(String str, StringBuffer strBuff){ StringBuffer sk = strBuff; str = str + " world"; sk.append(" world"); } public static void main (String[] args) { TestString10 t = new TestString10(); t.print(); } } What will be the output of the above code snippet?

Submit

7. Consider the following code snippet: import java.io.*; public class IOCode1 { public static void main(String args[]) throws IOException { BufferedReader br1 = new BufferedReader( new InputStreamReader(System.in)); BufferedWriter br2 = new BufferedWriter( new OutputStreamWriter(System.out)); String line = null; while( (line = br1.readLine()) != null ) { br2.write(line); br2.flush(); } br1.close(); br2.close(); } } What will be the output for the above code snippet?

Submit

8. What of the following is the default Scroll type for a ResultSet object?

Submit

9. Consider the following partial code: public class CreditCard { private String cardID; private Integer limit; public String ownerName; public void setCardInformation(String cardID, String ownerName, Integer limit) { this.cardID = cardID; this.ownerName = ownerName; this.limit = limit; } } Which of the following statement is True regarding the above given code?

Submit

10. Which of the following types of driver provides maximum decoupling between database and Java application?

Submit

11. Which of the following statements are true about String Arrays? (Choose 2)

Submit

12. Consider the following program: import java.io.*; public class SteppedTryCatch { public static void main(String[] args) { try { try { try { // Line 1 } catch(Exception e3) { System.out.println("Exception 1"); // Line 2 } } catch(IOException e2) { System.out.println("Exception 2"); // Line 3 } } catch(FileNotFoundException e1) { System.out.println("Exception 3"); } } } You need to make the above program to print the output as Exception 1 Exception 2 Exception 3 Which of the following when substituted in place of commented lines (// Line 1, Line 2 and Line 3) produce the desired output?

Submit

13. Consider the following code snippet: import java.util.*; public class TestCol3 { public static void main(String[] args) { List l = new ArrayList(); l.add("One"); l.add("Two"); l.add("Three"); l.add("Four"); l.add("One"); l.add("Four");  Set h = new HashSet(); h.addAll(l); System.out.println("Size:" + l.size() + h.size()); } } What will be the output of the following code snippet?

Submit

14. Consider the following code snippets: class GC2 { public GC2 getIt(GC2 gc2) { return gc2; } public static void main(String a[]) { GC2 g = GC2(); GC2 c = GC2(); c = g.getIt(c); } } How many objects are eligible for Garbage Collection?

Submit

15. Consider the following code: class Planet { } class Earth extends Planet { } public class WelcomePlanet { public static void welcomePlanet(Planet planet) { if (planet instanceof Earth) { System.out.println("Welcome!"); } else if (planet instanceof Planet) { System.out.println("Planet!"); } else { System.exit(0); } }  public static void main(String args[]) { WelcomePlanet wp = new WelcomePlanet(); Planet planet = new Earth(); welcomePlanet(planet); } } Which of the following will be the output of the above program?

Submit

16. 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

17. Consider the following code snippet: import java.util.*; public class TestCol6 { public static void main(String args[] ){ ArrayList a = new ArrayList(); // Line 1 a.add(new Integer(10)); a.add(new String("Hello")); a.add(new Double(34.9)); } } Which of the following code snippets when replaced at the line marked //Line 1, will make the ArrayList a to accept only Wrapper types of primitive numerics?

Submit

18. Consider the following: Class A contains the following: i. Instance Block ii. main() method iii. Static Block iv. Default Constructor of A Assume an instance of class A is created in the main() method. Which of the following gives the correct sequence of execution of above mentioned elements?

Submit

19. Which of the following options are true about Associations?(choose 2)

Submit

20. Consider the following code: public class Pass { static int j=20; public static void main(String argv[]) { int i=10; Pass p = new Pass(); p.amethod(i); System.out.println(i); System.out.println(j); } public void amethod(int x) { x=x*2; j=j*2; } } Which of the following gives the correct output for the above code?

Submit

21. To which of the following elements, annotations can be applied? (Choose 3)

Submit

22. Which of the following gives the correct sequence of execution of callback methods in a JUnit TestCase?

Submit

23. Consider the following program: 1. class CheckedException extends RuntimeException { } 2. class UncheckedException extends Exception { } 3. public class Check { 4. public static void main(String args[]) { 5. generateException1(); 6. generateException2(); 7. } 8. 9. private static void generateException1() { 10. throw new CheckedException(); 11. } 12. 13. private static void generateException2() { 14. throw new UncheckedException(); 15. } 16. } Which of the following is true regarding the above given program?

Submit

24. Which of the following pre-defined annotations requires that an annotation type should itself annotate with, in order to make the information in an user- defined annotation type appear in Javadoc-generated documentation?

Submit

25. State which of the following are default delimiters?(Choose 3)

Submit

26. Consider there are two threads, "Thread A" and "Thread B". "Thread A" holds a lock on "Object X". "Thread B" is blocked inside a wait call on Object X. Which of the following will make the "Thread B" runnable?

Submit

27. Which of the following statements are true? (choose 2)

Submit

28. Consider the following code: public class Code9 { public static void main(String args[]) { System.out.println(Math.abs(Integer.MIN_VALUE)); } } Which of the following will be the output for the above given program? (Choose 2)

Submit

29. Consider the following code: package com.java.test; public class A { public void m1() {System.out.print("A.m1, ");} protected void m2() {System.out.print("A.m2, ");} private void m3() {System.out.print("A.m3, ");} void m4() {System.out.print("A.m4, ");} } class B { public static void main(String[] args) { A a = new A(); a.m1(); // 1 a.m2(); // 2 a.m3(); // 3 a.m4(); // 4 } } Assume that both of the above classes are stored in a single source file called 'A.java'. Which of the following gives the valid output of the above code?

Submit

30. Consider the following program: class TestThread extends Thread { public static void main(String apps[]) { Thread t = null; TestThread tc = new TestThread(); for (int i =0;i<5;i++) { t = new Thread(tc); // Insert Code Here } } public void run() { System.out.println("Hello"); } } Which of the following code when substituted to the commented line (//Insert Code) will make the program to execute properly?

Submit

31. 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

32. Consider the following code segment: public class ExampleThree { public static void main(String args[]) { int i = 1; // Line 1 short s = 1; // Line 2 long l = 1; // Line 3 i = l + i; // Line 4 l = s + i; // Line 5 } } Which of the following gives the line in the above program that will result in error?

Submit

33. Consider the following scenario: An application needs to write a log file on the sequence of actions it takes while running. Which of the following stream classes can be used to implement the above requirement?

Submit

34. Consider the following code: class TM { public static void main(String a[]) { System.out.println(a[0]+a[0].length()+a.length); } } Select the valid inputs and outputs. (Choose 2)

Submit

35. Consider the following code: public class TH2 { public static synchronized void main(String[] args) throws InterruptedException { Thread t = new Thread(); t.start(); System.out.print("keep"); t.wait(10000); System.out.print("Smiling"); } } Which of the following gives the valid ouptut for the above code?

Submit

36. Which of the following statements is true about NavigableSet interface?

Submit

37. Consider the following code: 1. public class Boxer1{ 2. Integer i; 3. int x; 4. 5. public Boxer1(int y) { 6. x = i+y; 7. System.out.println(x); 8. } 9. 10. public static void main(String[] args) { 11. new Boxer1(new Integer(4)); 12. } 13. } Which of the following will be the output of the above program?

Submit

38. Which of the following options are true? (Choose 2)

Submit

39. Consider the following code: public class ThrowsException { static void throwMethod() { System.out.println("Inside throwMethod."); throw new IllegalAccessException("exception"); } public static void main(String args[]) { try { throwMethod(); } catch (IllegalAccessException e) { System.out.println("Caught " + e); } } } Which of the following gives the output for the above given code?

Submit

40. Which of the following options give the names of the data structures that can be used for Range-View operations, but no nulls?(choose 2)

Submit

41. Which of the following classes is used to handle the abnormal situation that may occur during database calls using JDBC API?

Submit

42. Consider the following code snippet: interface InterfaceOne { int ID = 10; int getAccess(); } interface InterfaceTwo { int ID = 20; int getAccess(); } class InterfaceImpl implements InterfaceOne, InterfaceTwo { public int getAccess() { if (this instanceof InterfaceOne) { return InterfaceOne.ID; } else { return InterfaceTwo.ID; } } } public class Code { public static void main(String args[]) { InterfaceOne i1 = new InterfaceImpl(); System.out.println(i1.getAccess());  InterfaceTwo i2 = (InterfaceTwo) i1; System.out.println(i2.getAccess()); } } Which of the following will be the output for the above code snippet?

Submit

43. Consider the following code: class A is defined in packageone as follows: package com.packageone; public class A { private int x; public A(int x) { this(); this.x = x; } abstract void print(); } And class B is defined in packagetwo as follows: package com.packagetwo; import com.packageone.A; class B extends A { B(int x) { super(x); } void print() { System.out.println(x); } } class C { public static void main(String args[]) { A a = new B(10); } } Which of the following changes will make the code to run properly? (Choose 3)

Submit

44. Which of the following statements are true regarding equals() method?(Choose 3)

Submit

45. Consider the following code snippet: public class Demo extends Object { String Title; public Demo( String t ){ Title = t; } public void showTitle() { System.out.println( "Title is " + Title ); } } class DerivedDemo extends Demo { public void setTitle( String tt ) { Title = tt ; } } public class TasteIt { public static void main(String args[]) { DerivedDemo dd = new DerivedDemo(); dd.showTitle(); Which of the following option will be the output for the above code snippet?

Submit
×
Saved
Thank you for your feedback!
View My Results
Cancel
  • All
    All (45)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
Consider s1 and s2 are sets....
Which of the following is the process of creating a new class from an...
Consider the following code:...
Consider the following code:...
Consider the following code:...
Consider the following code snippet:...
Consider the following code snippet:...
What of the following is the default Scroll type for a ResultSet...
Consider the following partial code:...
Which of the following types of driver provides maximum decoupling...
Which of the following statements are true about String Arrays?...
Consider the following program:...
Consider the following code snippet:...
Consider the following code snippets:...
Consider the following code:...
A monitor called 'mon' has 5 threads in its waiting pool; all...
Consider the following code snippet:...
Consider the following:...
Which of the following options are true about Associations?(choose 2)
Consider the following code:...
To which of the following elements, annotations can be applied?...
Which of the following gives the correct sequence of execution of...
Consider the following program:...
Which of the following pre-defined annotations requires that an...
State which of the following are default delimiters?(Choose 3)
Consider there are two threads, "Thread A" and "Thread...
Which of the following statements are true? (choose 2)
Consider the following code:...
Consider the following code:...
Consider the following program:...
Consider the following code:...
Consider the following code segment:...
Consider the following scenario:...
Consider the following code:...
Consider the following code:...
Which of the following statements is true about NavigableSet...
Consider the following code:...
Which of the following options are true? (Choose 2)
Consider the following code:...
Which of the following options give the names of the data structures...
Which of the following classes is used to handle the abnormal...
Consider the following code snippet:...
Consider the following code:...
Which of the following statements are true regarding equals()...
Consider the following code snippet:...
play-Mute sad happy unanswered_answer up-hover down-hover success oval cancel Check box square blue
Alert!