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 TestException2 { static double testException(int x, int y) { return (x/y); } public static void main(String[] args) { try { double p = testException(10,5); System.out.println("p = "+p); } catch(Exception e) { System.out.println("Exception happened "+e.getMessage()); return; } finally { System.out.println("In finally"); } } }

  1. p = 2.0

  2. Compiler Error

  3. Exception

  4. p = 2.0 In finally


Correct Option: D

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<stdio.h> int main() { int p[]={1,2,3}; printf("%d %d",p,(&p)+1); } If address of p is -123456 and int occupies 4 bytes then what would be the output?

  1. Compile Time Error

  2. -123456, -123460

  3. -123456, -123444

  4. -123456, -123452

  5. None of the above


Correct Option: C
  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() { char s1[]="Dennis"; char s2[]="Dennis"; if(s1 == s2) printf(" The man behind C"); else printf(" Experience the legacy of 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
- Hide questions