0

programming languages Online Quiz - 182

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

What is the output of following code snippet ? void main() { printf(printf("anna")); }

  1. anna

  2. compile time error

  3. anna4

  4. non of the above

  5. garbage


Correct Option: C

What is the output of following code snippet ? void main() { int arr[5]={10,20,30,40,50}; printf("%d",(arr+2)); }

  1. 30

  2. 20

  3. syntax error

  4. garbage


Correct Option: D
  1. 4

  2. 2

  3. 8

  4. The number of bytes to represent an int is compiler dependent.


Correct Option: A
  1. synchronized

  2. friend

  3. implement

  4. throws


Correct Option: A,D

What gets printed when the following program is compiled and run? class test { public static void main(String args[]) { int i,j,k,l=0; k = l++; j = ++k; i = j++; System.out.println(i); } }

  1. 1

  2. 3

  3. 2

  4. 0


Correct Option: A

What gets printed when the following program is compiled and run. protected class example {public static void main(String args[]) {String test = "abc";test = test + test;System.out.println(test);}}

  1. The program does not compile because statement "test = test + test" is illegal.

  2. The program prints "abc"

  3. The program prints "abcabc"

  4. The class does not compile because the top level class cannot be protected.


Correct Option: D

package inheritance; public class TestInheritance3 { protected int p = 100; } package inheritance1; import inheritance.TestInheritance3; public class TestInheritance_3 extends TestInheritance3 { void printP() { System.out.println("p= "+p); } public static void main(String[] args) { TestInheritance_3 T_3 = new TestInheritance_3(); T_3.printP(); } }

  1. p= 0

  2. p= 100

  3. Compiler Error

  4. Exception


Correct Option: B

package inheritance; public class TestInheritance7{ protected int p = 100; } package inheritance1; import inheritance.TestInheritance7; public class TestInheritance_7 extends TestInheritance7{ void printP() { TestInheritance7 T7 = new TestInheritance7(); System.out.println("p = "+T7.p); } public static void main(String[] args) { TestInheritance_7 T_7 = new TestInheritance_7(); T_7.printP(); } }

  1. p = 100

  2. Compiler error

  3. p = 0

  4. Exception


Correct Option: B
- Hide questions