0
Alien head

programming languages Online Quiz - 129

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

What will happen if you try to compile and run the following code? public class Q { public static void main(String argv[]){ int anar[]=new int[5]; System.out.println(anar[0]); } }

  1. Error: anar is referenced before it is initialized

  2. null

  3. 0

  4. 5


Correct Option: C

What will happen when you compile and run the following code? public class MyClass{ static int i; public static void main(String argv[]){ System.out.println(i); } }

  1. Error Variable i may not have been initialized

  2. null

  3. 1

  4. 0


Correct Option: D

Which of the following are legal identifiers?

  1. 2variable

  2. variable2

  3. _whatavariable

  4. 3

  5. #myvar

  6. $anothervar


Correct Option: B,C,D,F

Can I have multiple methods in the same class?

  1. True

  2. False


Correct Option: B

Difference between Swing and AWT?

  1. AWT are light-weight componenets. Swings are heavy-weight components.

  2. AWT is platform independent. SWING is platform dependent.

  3. AWT are heavy-weight componenets. Swings are light-weight components.

  4. None of the above


Correct Option: C

How you can force the garbage collection?

  1. Using delete operator

  2. Using destructor

  3. Garbage collection is an automatic process & cant be forced.

  4. None of the above


Correct Option: C

Read the following program: public class test { public static void main(String [] args) { int x = 3; int y = 1; if (x = y) System.out.println("Not equal"); else System.out.println("Equal"); } } What is the result?

  1. The output is “Equal”

  2. The output in “Not Equal”

  3. An error at " if (x = y)" causes compilation to fall.

  4. The program executes but no output is show on console.


Correct Option: C

A continue statement causes execution to skip to

  1. the return 0; statement

  2. the first statement after the loop

  3. the statement following the continue statement

  4. the next iteration of the loop


Correct Option: D

Which looping process checks the test condition at the end of the loop?

  1. for

  2. while

  3. do-while

  4. no looping process checks the test condition at the end


Correct Option: C

Each pass through a loop is called a/an

  1. enumeration

  2. iteration

  3. culmination

  4. pass through


Correct Option: B

What's wrong? (x = 4 && y = 5) ? (a = 5) ; (b = 6);

  1. the question mark should be an equal sign

  2. the first semicolon should be a colon

  3. there are too many variables in the statement

  4. the conditional operator is only used with apstrings


Correct Option: B

If there is more than one statement in the block of a for loop, which of the following must be placed at the beginning and the ending of the loop block?

  1. parentheses ( )

  2. braces { }

  3. brackets [ ]

  4. arrows < >


Correct Option: B

What's wrong? while( (i < 10) && (i > 24))

  1. the logical operator && cannot be used in a test condition

  2. the while loop is an exit-condition loop

  3. the test condition is always false

  4. the test condition is always true


Correct Option: C

What's wrong? for (int k = 2, k <=12, k++)

  1. the increment should always be ++k

  2. the variable must always be the letter i when using a for loop

  3. there should be a semicolon at the end of the statement

  4. the commas should be semicolons


Correct Option: D

Which looping process is best used when the number of iterations is known?

  1. for

  2. while

  3. do-while

  4. all looping processes require that the iterations be known


Correct Option: A

The statement i++; is equivalent to

  1. i = i + i;

  2. i = i - 1;

  3. i = i + 1;

  4. i --;


Correct Option: C

In a group of nested loops, which loop is executed the most number of times?

  1. the outermost loop

  2. the innermost loop

  3. all loops are executed the same number of times

  4. cannot be determined without knowing the size of the loops


Correct Option: B

A continue statement causes execution to skip to

  1. the next iteration of the loop

  2. the first statement after the loop

  3. the statement following the continue statement

  4. the return 0; statement


Correct Option: A

Which looping process checks the test condition at the end of the loop?

  1. for

  2. while

  3. do-while

  4. no looping process checks the test condition at the end


Correct Option: C

Each pass through a loop is called a/an

  1. enumeration

  2. iteration

  3. culmination

  4. pass through


Correct Option: B
+ View questions