0

programming languages Online Quiz - 340

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

Consider the following piece of code: 1 long i = 2 ; 2 switch (i) { 3 case 1: 4 System.out.println ("Case 1"); 5 case 2: 6 System.out.println ("Case 2"); 7 case 3: 8 System.out.println ("Case 3"); 9 default: 10 System.out.println ("Default"); 11 } Which of the following lines will be included in the output? (Choose all that apply, please bear with code as formating it sems is not possible,first numbers represent line numbers)

  1. Case 1

  2. Case 2

  3. Case 3

  4. Default

  5. Compiler Error


Correct Option: E

In Java the compiler will always insert a default , no argument constructor into any class definition

  1. True

  2. False


Correct Option: B

In a method call when an object reference is passed as an argument , So what gets passed actually ?

  1. The object itself

  2. a copy of reference

  3. the original reference

  4. a reference to a copy


Correct Option: B

consider the following scenarioint i = 0;if ( i ) {System.out.println("This won't print");}else{System.out.println("This prints");}

  1. This won't print

  2. This prints

  3. There's a runtime exception

  4. scenario is not legal


Correct Option: D

A constructor can be declared abstract

  1. True

  2. False


Correct Option: B

The legal values for a boolean in java are choose all that applies

  1. 1,0

  2. TRUE,FALSE

  3. true , false , TRUE,FALSE

  4. true , false


Correct Option: D

Its possible for a non-abstract class to have abstract methods.

  1. True

  2. False


Correct Option: B

The following statement would allocate memory on? char *ptr = malloc(10);

  1. Stack

  2. Heap

  3. Code Segment

  4. Data Segment


Correct Option: B

In the following code variable test would be created on? static int test;

  1. Heap

  2. Stack

  3. Code Segment

  4. Data Segment


Correct Option: D

In the following code variable test1 would be allocated memory on?int func(){int test1 = 10;return test1;}void main(){ int i = 0; i = func();}

  1. Heap

  2. Stack

  3. Code Segment

  4. Data Segment


Correct Option: B

In the following segments which is the read only segment?

  1. Heap

  2. Stack

  3. Code Segment

  4. Data Segment


Correct Option: C

Can a constructor be declared as private?

  1. True

  2. False


Correct Option: A

The access modifier of an overloaded method is different. Is this valid?

  1. True

  2. False


Correct Option: A

The following code is compiled: double abc = 100.0; double xyz = abc/0; What is the result?

  1. Compilation Error

  2. Arithmetic Exception

  3. Compiles with no errors

  4. None of the above


Correct Option: C

Consider the following case: A return statement is there in the catch block. An exception occurs and is caught. Now will the finally block be executed?

  1. will execute

  2. will not execute

  3. Compilation Error

  4. Runtime Exception


Correct Option: A

Overloaded methods should not throw new checked exceptions that have not been thrown by the original method?

  1. True

  2. False


Correct Option: B

Consider the following case: A = false B = true; What is the result of A && B ?

  1. True

  2. False


Correct Option: B

Consider the following case; int i; int k; for(i=0;k<10;i++){/* The body */} This will not compile?

  1. True

  2. False


Correct Option: B
- Hide questions