0

programming languages Online Quiz - 100

Description: programming languages Online Quiz - 100
Number of Questions: 20
Created by:
Tags: programming languages
Attempted 0/20 Correct 0 Score 0
  1. Type 4 driver

  2. Type 3 driver

  3. Type 2 driver

  4. Type 1 driver


Correct Option: D
  1. PreparedStatement

  2. ParameterizedStatement

  3. ParameterizedStatement and CallableStatement

  4. All kinds of Statements (i.e. which implement a sub interface of Statement)


Correct Option: B

Given: 11. public static void main(String[] args) { 12. Object obj =new int[] { 1,2,3 }; 13. int[] someArray = (int[])obj; 14. for (int i: someArray) System.out.print(i +“ “) 15. } ‘What is the result?

  1. 1 2 3

  2. B. Compilation fails because of an error in line 12.

  3. B. Compilation fails because of an error in line 13.

  4. B. Compilation fails because of an error in line 14.


Correct Option: A

Given: 12. public class Test { 13. public enum Dogs {collie, harrier}; 14. public static void main(String [] args) { 15. Dogs myDog = Dogs.collie; 16. switch (myDog) { 17. case collie: 18. System.out.print(”collie “); 19. case harrier: 20. System.out.print(”harrier “); 21. } 22. } 23. } What is the result?

  1. collie

  2. harrier

  3. Compilation fails

  4. collie harrier


Correct Option: D

Given: 33. try { 34. // some code here 35. } catch (NullPointerException e1) { 36. System.out.print(”a”); 37. } catch (RuntimeException e2) { 38. System.out.print(”b”); 39. } finally { 40. System.out.print(”c”); 41. } What is the result if a NullPointerException occurs on line 34?

  1. c

  2. a

  3. ab

  4. ac

  5. bc


Correct Option: D

Given: 10. public class Foo implements java.io.Serializable { 11. private int x; 12. public int getX() { return x; } 12.publicFoo(int x){this.x=x; } 13. private void writeObject( ObjectOutputStream s) 14. throws IOException { 15. // insert code here 16. } 17. } Which code fragment, inserted at line 15, will allow Foo objects to be correctly serialized and deserialized?

  1. s.writeInt(x);

  2. s.serialize(x);

  3. s.writeObject(x);

  4. s.defaultWriteObject();


Correct Option: D
  1. An encapsulated, public class promotes re-use.

  2. Classes that share the same interface are always tightly

  3. An encapsulated class allows subclasses to overload methods, but

  4. An encapsulated class allows a programmer to change an


Correct Option: A,D
  1. abstract double area() { }

  2. abstract double area()

  3. abstract double area();

  4. abstract double area(); { }


Correct Option: C
  1. Compilation fails.

  2. An exception is thrown at runtime.

  3. The code executes normally and prints “bar”.

  4. The code executes normally, but nothing prints.


Correct Option: C

Given: 1. public class TestOne { 2. public static void main (String[] args) throws Exception { 3. Thread.sleep(3000); 4. System.out.println(”sleep”); 5. } 6. } What is the result?

  1. Compilation fails.

  2. An exception is thrown at runtime.

  3. The code executes normally and prints “sleep”.

  4. The code executes normally, but nothing is printed.


Correct Option: C

foo and bar are public references available to many other threads. foo refers to a Thread and bar is an Object. The thread foo is currently executing bar.wait(). From another thread, which statement is the most reliable way to ensue that foo will stop executing wait()?

  1. foo.notify();

  2. bar.notify();

  3. foo.notifyAll();

  4. Thread.notify();

  5. bar.notiFYAll();

  6. Object.notify();


Correct Option: E
  1. A finalizer may NOT be invoked explicitly.

  2. The finalize method declared in class Object takes no action.

  3. super.finalize() is called implicitly by any overriding finalize method.

  4. The finalize method for a given object will be called no more than

  5. The order in which finalize will be called on two objects is based on


Correct Option: B,D

Given: 34. HashMap props = new HashMap(); 35. props.put(”key45”, “some value”); 36. props.put(”key12”, “some other value”); 37. props.put(”key39”, “yet another value”); 38. Set s = props.keySet(); 39. // insert code here What, inserted at line 39, will sort the keys in the props HashMap?

  1. Arrays.sort(s);

  2. s = new TreeSet(s);

  3. Collections.sort(s);

  4. s = new SortedSet(s);


Correct Option: B
  1. Inheritance represents an is-a relationship.

  2. Inheritance represents a has-a relationship.

  3. Interfaces must be used when creating a has-a relationship.

  4. Instance variables can be used when creating a has-a relationship.


Correct Option: A,D
  1. The return type for a method can be any Java type, including void

  2. An important principal of object oriented programming is implementation hiding

  3. When you perform mathematical calculations on the unlike data type, java will perform a implicit conversion to unify the types

  4. All the Above


Correct Option: D
- Hide questions