0

programming languages Online Quiz - 179

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

package exceptions; public class TestException3 { static double testException(int x, int y) { return (x/y); } public static void main(String[] args) { try { double p = testException(10,0); System.out.println("p = "+p); } catch(Exception e) { System.out.println("Exception happened "+e.getMessage()); System.exit(0); } finally { System.out.println("In finally"); } } }

  1. Compiler Error

  2. Exception happened / by zero

  3. Exception happened / by zero In finally

  4. In finally


Correct Option: B

package exceptions; public class TestException1 { static double testException(int x, int y) { return (x/y); } public static void main(String[] args) { try { double p = testException(10,0); System.out.println("p = "+p); System.out.println("Division done"); } catch(Exception e) { System.out.println("Exception happened "+e.getMessage()); } finally { System.out.println("In finally"); } } }

  1. Exception happened / by zero In finally

  2. Exception happened / by zero

  3. In finally

  4. Compiler Error


Correct Option: A

#include int main () { ;;;;;; " Please Execute Me " ;;;;; // Line 6 printf(" Executing... ") // Line 7 ;;;;;; "Executed" ;;;;;;; // Line 8 }

  1. Executing...

  2. Please Execute Me Executing... Executed

  3. Error at line 6

  4. Error Semicolon missing


Correct Option: A
  1. 1 1.000000

  2. 1 1.500000

  3. 0 1.000000

  4. 1 0.000000


Correct Option: D
  1. Error : Semicolon Missing

  2. Error: Misplaced Else

  3. I is odd

  4. I is odd I is Even

  5. No Output


Correct Option: D

#include int main() { float dennis; switch(dennis) { default: printf("Let me work"); case 1: printf("This is case 1"); case 2: printf("This is case 2"); break; } }

  1. Let me work

  2. Let me workThis is case 1This is case 2

  3. Compilation Error

  4. Run Time Error


Correct Option: C
  1. The man behind C

  2. Experience the legacy of C

  3. Error : == operator cannot be applied to reference data types

  4. boolean cannot be converted to int


Correct Option: B
  1. 777777.........

  2. Compilation Error

  3. 7

  4. None of the above


Correct Option: C

package testswitch; public class TestSwitch { public static void main(String[] args) { int x = 2; switch (x) { default: System.out.println("Default"); break; case 3: System.out.println("I am in 3"); break; case 2: System.out.println("I am in 2"); break; } } }

  1. I am in 2

  2. Default I am in 2

  3. Default

  4. Compiler Error


Correct Option: A

package testswitch; public class TestSwitch1 { public static void main(String[] args) { int m=100; switch(100) { case m: System.out.println("in m"); default :System.out.println("default"); } } }

  1. in m Default

  2. Compiler Error

  3. in m

  4. default


Correct Option: B

package testswitch; public class TestSwitch5 { public static void main(String[] args) { char a = 'a'; switch (a) { default: System.out.println("I am in default"); break; case 'a': System.out.println("I am in a"); break; } } }

  1. I am in a

  2. I am in default

  3. Exception

  4. Compiler Error


Correct Option: A
- Hide questions