0
Alien head

programming languages Online Quiz - 192

Description: programming languages Online Quiz - 192
Number of Questions: 20
Created by:
Tags: programming languages
Attempted 0/20 Correct 0 Score 0

In the init(ServletConfig) method of Servlet life cycle, what method can be used to access the ServletConfig object

  1. getServletInfo()

  2. getInitParameters()

  3. getServletConfig()

  4. None of the above


Correct Option: C

What is the output of following piece of code ? int x = 2; switch (x) { case 1:System.out.println(”1?); case 2: case 3:System.out.println(”3?); case 4: case 5:System.out.println(”5?);

  1. No output

  2. 3 and 5

  3. 1, 3 and 5

  4. 3


Correct Option: B

A method is defined in a class as : void processUser(int i) { } If this method is overriden in a sub class,

  1. the new method should return int

  2. the new method can return any type of values

  3. the argument list of new method should exactly match that of overriden method

  4. the return type of new method should exactly match that of overriden method


Correct Option: C,D

Stateful Session beans contain

  1. Home Interface

  2. Remote Interface

  3. Bean Class

  4. All of the above


Correct Option: D

Which of the following is true ?

  1. Stateless session beans doesn’t preserve any state across method calls

  2. Stateful session beans can be accesses by multiple users at the same time

  3. None of the above

  4. Allof the above


Correct Option: A

Which is the data structure used to store sorted map elements

  1. HashSet

  2. Hashmap

  3. Map

  4. TreeMap


Correct Option: D

A Vector is declared as follows. What happens if the code tried to add 6 th element to this Vector new vector(5,10)

  1. The element will be successfully added

  2. ArrayIndexOutOfBounds Exception

  3. The Vector allocates space to accommodate up to 15 elements

  4. None of the above


Correct Option: A,C

The Java interpreter is used for the execution of the source code.

  1. True

  2. False


Correct Option: A

Java runs on.

  1. Windows

  2. Unix

  3. Solaris

  4. All of the above


Correct Option: D

What type of inheritance does Java have?

  1. Single Inheritence

  2. Double Inheritence

  3. Multiple Inheritence

  4. Class Inheritence


Correct Option: A

class A extends Thread { public void run() { System.out.print("A"); } } class B { public static void main (String[] args) { A a = new A(); a.start(); a.start(); // 1 } }

  1. Run Time Exception

  2. Compile Error

  3. the code compile and runs fail

  4. None of the above


Correct Option: A

class C1{ public void m1(){ // 1 } } class C2 extends C1{ //2 private void m1(){ } }

  1. compile time error at line1

  2. compile time error at line2

  3. Run time exception

  4. None Of the above


Correct Option: B

interface I{ void f1(); // 1 public void f2(); // 2 protected void f3(); // 3 private void f4(); // 4 } which lines generate compile time errors?

  1. compiletime error at lines 1,2,3,4

  2. compiletime error at line 3

  3. compiletime error at line 1

  4. compiletime error at lines 3,4


Correct Option: D

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?

  1. 1,3

  2. 2,3

  3. Compilation Error

  4. Exception


Correct Option: B

What happens when you compare two primitives of different numerical types?

  1. compiler error

  2. smaller type is promoted

  3. must explicitly cast

  4. none of the above


Correct Option: B

All exceptions inherit from

  1. java.lang.Exception

  2. java.lang.Error

  3. java.lang.Throwable

  4. none of the above


Correct Option: C

A class can define two methods with the same name as long as the return types are different

  1. True

  2. False


Correct Option: B

Assume the bit pattern of byte x is: 10110001. What will the sign of x be after x>>2?

  1. postive

  2. negative

  3. can't be find

  4. none of the above


Correct Option: B

Are you allowed to have more than one top-level(non-inner) class definition per source file?

  1. True

  2. False


Correct Option: A

What happens when you compare two primitives of different numerical types?

  1. compiler error

  2. smaller type is promoted

  3. must explicitly cast

  4. none of the above


Correct Option: B
+ View questions