Dd

44 Questions | Attempts: 481
Share

SettingsSettingsSettings
Dd - Quiz

Questions and Answers
  • 1. 
    Which of the following are true about ResultSet? (Choose 2)  
    • A. 

      Atleast one record should be there in the ResultSet onopening a query (or) table

    • B. 

      Not all ResultSets are updatable

    • C. 

      The ResultSet object contains null, if there are no records inthe table

    • D. 

      It is possible to delete records through ResultSet

    • E. 

      All ResultSet, are Scrollable

  • 2. 
    Consider the following code: import java.util.*; public class Code10 { { final Vector v; v=new Vector(); } public Code10() { } public void codeMethod() { System.out.println(v.isEmpty()); } public static void main(String args[]) { new Code10().codeMethod(); } } Which of the following will be the output for the above code?
    • A. 

      Prints: false

    • B. 

      Runtime error: NullPointerException

    • C. 

      Compilation error: cannot find the symbol

    • D. 

      Compilation error: v is not initialised inside the constructor

    • E. 

      Prints: true

  • 3. 
    Consider the following scenario: Mr.Vijay is working for a Software Company. He needs to save and reload objects from a Java application. He needs to write a module to accomplish the same. Which of the following options can be used to accomplish the above requirement?
    • A. 

      Writable interface

    • B. 

      Readable interface

    • C. 

      ObjectSerializable interface

    • D. 

      Cloneable interface

    • E. 

      Serializable interface

  • 4. 
    class InOut{ String s= new String("Between"); public void amethod(final int iArgs){ int iam; class Bicycle{ public void sayHello(){ ...Line 1 } }//End of bicycle class }//End of amethod public void another(){ int iOther; } } Which of the following statements would be correct to be coded at ...Line 1? (Choose 2)
    • A. 

      System.out.println(iOther);

    • B. 

      System.out.println(iam);

    • C. 

      System.out.println(iArgs);

    • D. 

      System.out.println(s);

  • 5. 
    Which of the following modifiers cannot be used with the abstract modifier in a method declaration?(Choose 3)
    • A. 

      Synchronized

    • B. 

      Final

    • C. 

      Public

    • D. 

      Protected

    • E. 

      Private

  • 6. 
    Consider the following code: public class LabeledBreak2 { public static void main(String args[]) { loop: for(int j=0; j<2; j++) { for(int i=0; i<10; i++) { if(i == 5) break loop; System.out.print(i + " "); } } } } Which of the following will be the output for the above code?
    • A. 

      0 1 2 3 4 5

    • B. 

      Indefinite Loop

    • C. 

      1 2 3 4 5

    • D. 

      0 1 2 3 4

    • E. 

      0 1 2 3 4 0 1 2 3 4

  • 7. 
    Consider the following code: public class Key1 { public boolean testAns( String ans, int n ) { boolean rslt; if (ans.equalsIgnoreCase("YES") & n > 5) rslt = true; return rslt; } public static void main(String args[]) { System.out.println(new Key1().testAns("no", 5)); } } Which of the following will be the output of the above program?
    • A. 

      NO

    • B. 

      True

    • C. 

      Compile-time error

    • D. 

      Runtime Error

    • E. 

      False

  • 8. 
    Which of the following is the immediate super interface of CallableStatement?
    • A. 

      CallableStatement

    • B. 

      PreparedStatement

    • C. 

      ResultSet

    • D. 

      Statement

    • E. 

      Connection

  • 9. 
    Consider the following code: public class UnwiseThreads implements Runnable { public void run() { while(true) { } } public static void main(String args[]) { UnwiseThreads ut1 = new UnwiseThreads(); UnwiseThreads ut2 = new UnwiseThreads(); UnwiseThreads ut3 = new UnwiseThreads(); ut1.run(); ut2.run(); ut3.run(); } } Which of the following is correct for the above given program?
    • A. 

      Compilation error "ut2.run() is never reached"

    • B. 

      The code compiles and runs 3 non ending non daemon threads

    • C. 

      The code compiles but runs only 1 non ending, non daemon thread

    • D. 

      Runtime Error "IllegalThreadStateException"

  • 10. 
    Which of the following is the best-performing implementation of Set interface?
    • A. 

      LinkedHashSet

    • B. 

      TreeSet

    • C. 

      Hashtable

    • D. 

      SortedSet

    • E. 

      HashSet

  • 11. 
    12 Consider the following scenario: Real Chocos Private Limited deals in manufacturing variety of chocolates. This organization manufactures three varieties of chocolates. 1. Fruit Chocolates 2. Rum Chocolates 3. Milk Chocolates A software system needs to be built. Which of the following options identifies the Classes and Objects?
    • A. 

      Class: Real Chocos Private Limited Objects: Chocolate

    • B. 

      Class: Chocolate Objects: Fruit Chocolates, Rum Chocolates, Milk Chocolates

    • C. 

      Class: Choclate Objects: Milk Chocolates

    • D. 

      Class: Fruit Chocolates Objects: Rum Chocolates

  • 12. 
    Consider the following code snippet: class Animal { String name; public boolean equals(Object o) { Animal a = (Animal) o; // Code Here } } class TestAnimal { public static void main(String args[]) { Animal a = new Animal(); a.name = "Dog"; Animal b = new Animal(); b.name = "dog"; System.out.println(a.equals(b)); } } Which of the following code snippets should be replaced for the comment line (//Code Here) in the above given code, to get the output as true?
    • A. 

      Return this.name.equalsIgnoreCase(a.name);

    • B. 

      Return this.name.equals(a.name);

    • C. 

      Return super.equals(a);

    • D. 

      Return this.name == a.name;

    • E. 

      Return this.name.hashCode() == a.name.hashCode();

  • 13. 
    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?
    • A. 

      Throws ClassCastException at runtime

    • B. 

      Prints: B

    • C. 

      Compilation Error 'Cannot find the symbol'

    • D. 

      Prints: A

  • 14. 
    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?
    • A. 

      An exception is thrown at runtime

    • B. 

      Planet!

    • C. 

      The code runs with no output

    • D. 

      Welcome!

    • E. 

      Compilation fails

  • 15. 
    Consider the following code: public class Code13 { public static void main(String... args) { for(String s:args) System.out.print(s + ", "); System.out.println(args.length); } } Which of the following will be the output if the above code is attempted to compile and execute?
    • A. 

      Program compiles successfully and prints the passed arguments as comma separated values and finally prints the length of the arguments-list

    • B. 

      Runtime Error: NoSuchMethodError

    • C. 

      Variable arguments cannot be used with enhanced for-loop

    • D. 

      Compilation Error: var-args cannot be used as arguments for main() method

  • 16. 
    Consider the following code: class UT1 { static byte m1() { final char c = 'u0001'; return c; } static byte m3(final char c) {return c;} public static void main(String[] args) { char c = 'u0003'; System.out.print(""+m1()+m3(c)); } } Which of the following gives the valid output of the above code?
    • A. 

      Compile-time error

    • B. 

      Prints: 13

    • C. 

      Run-time error

    • D. 

      Prints: 4

    • E. 

      None of the listed options

  • 17. 
    An Annotation Type ________________.
    • A. 

      Is a meta-tag used to pass message between the code and JVM.

    • B. 

      Defines the structure of an interface

    • C. 

      Defines the structure of an Application

    • D. 

      Defines the structure of an Object

    • E. 

      Defines the structure of an Annotation

  • 18. 
    Which of the following are correct regarding HashCode?(Choose 2)
    • A. 

      It improves performance

    • B. 

      The numeric key is unique

    • C. 

      It is a 32 bit numeric digest key

    • D. 

      HashCode() is defined in String class

    • E. 

      HashCode() value cannot be a zero-value

  • 19. 
    Given the following object hierarchy and code for the upgrade method: java.lang.Object +----mypkg.BaseWidget | +----TypeAWidget // the following is a method in the BaseWidget class 1. public TypeAWidget upgrade( ){ 2. TypeAWidget A = (TypeAWidget) this; 3. return A; 4. } Which of the following will be the result of the below statements? 5. BaseWidget B = new BaseWidget(); 6. TypeAWidget A = B.upgrade();
    • A. 

      The compiler would object to line 2.

    • B. 

      A runtime ClassCastException would be generated in line 2.

    • C. 

      As this referes to the BaseWidget, a parent can accept itschild

    • D. 

      After line 6 executes, the object referred to as A will in factbe a TypeAWidget.

  • 20. 
    Consider the following program: public class ThreadJoin extends Thread{ public static void main(String[] args) { Thread t1 = new Thread("T1"); Thread t2 = new Thread("T2"); try { t1.join(); t2.join(); } catch (InterruptedException e) { System.out.println("Main Thread interrupted."); } } public void run(){ System.out.println("Run executed"); } } What will be the output of the above program?
    • A. 

      Run-time error

    • B. 

      Compile-time error

    • C. 

      Prints "Main Thread interrupted."

    • D. 

      Program ends without printing anything

    • E. 

      Prints "Run executed" twice

  • 21. 
    Which are all platform independent among the following? (Choose 3)
    • A. 

      JAR Files

    • B. 

      Java Virtual Machine (JVM)

    • C. 

      Java Development Kit (JDK)

    • D. 

      Java Class Files

    • E. 

      Java Source Files

  • 22. 
    Which of the following options is true about multiple inheritance?
    • A. 

      Inheriting from a class which is already in an inheritancehierarchy

    • B. 

      Inheriting from more than one super class

    • C. 

      Inheriting from two super classes

    • D. 

      Inheriting from a single class

  • 23. 
    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)
    • A. 

      List

    • B. 

      SortedSet

    • C. 

      Set

    • D. 

      ArrayList

    • E. 

      TreeSet

  • 24. 
    Which of the following options are true for StringBuffer class?(choose 3)
    • A. 

      'capacity' property indicates the maximum number ofcharacters that a StringBuffer can have

    • B. 

      StringBuffer is extended from String class

    • C. 

      StringBuffer implements Charsequence interface

    • D. 

      StringBuffer is threadsafe

    • E. 

      Buffer space in StringBuffer can be shared

  • 25. 
    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?
    • A. 

      The class is fully encapsulated

    • B. 

      The setCardInformation method breaks encapsulation

    • C. 

      The code demonstrates polymorphism

    • D. 

      The cardID and limit variables break polymorphism

    • E. 

      The ownerName variable breaks encapsulation

Back to Top Back to top
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.