0

programming languages Online Quiz - 101

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

"What do you think the output of the following code snippet will be? 01 WS-NUM-TEST PIC +9(2).99. 01 WS-NUM-TEST2 PIC -9(2).99. MOVE 19.99 TO WS-NUM-TEST MOVE -9.99 TO WS-NUM-TEST2 IF WS-NUM-TEST > WS-NUM-TEST2 DISPLAY ""+VE GREATER THAN -VE"" ELSE DISPLAY ""+VE LESS THAN -VE"" END-IF "

  1. +VE GREATER THAN -VE

  2. +VE LESS THAN -VE

  3. Compile error

  4. Edited Numeric field cannot be used for comparison.


Correct Option: C
  1. foreach(x) System.out.println(z);

  2. for(int z : x) System.out.println(z);

  3. while( x.hasNext()) System.out.println( x.next());

  4. for( int i=0; i< x.length; i++ ) System.out.println(x[i]);


Correct Option: B,D
  1. The instance gets garbage collected.

  2. The code on line 33 throws an exception.

  3. The code on line 35 throws an exception.

  4. The code on line 31 throws an exception.

  5. The code on line 33 executes successfully.


Correct Option: B,C,E

What will be the output of the below code snippet? public class Quiz4 { public static void main(String args[]) { int j = 0; for (int i = 0; i < 100; i++) j = j++; System.out.println(j); } }

  1. 99

  2. 0

  3. 100

  4. 101


Correct Option: B

What will be the output of the below code snippet? public class Quiz5 { public static void main(String args[]) { int i = 0; while (-1 << i != 0) i++; System.out.println(i); } }

  1. 32

  2. Infinite Loop

  3. 16

  4. 64


Correct Option: B

What will be the output of the below code snippet? public class Quiz6 { public static void main(String[] args) { System.out.println(decision()); } static boolean decision() { try { return true; } finally { return false; } } }

  1. True

  2. False

  3. Compilation Error

  4. Run Time Error


Correct Option: B

What will be the output of the below code snippet? public class Quiz7 { public static void main(String[] args) { try { System.out.println("Hello world"); System.exit(0); } finally { System.out.println("Goodbye world"); } } }

  1. Hello world \n Goodbye world

  2. Hello world

  3. Compilation Error

  4. Run Time Error


Correct Option: B

What will be the output of the below code snippet? public class Quiz8 { class Base { public String className = "Base"; } class Derived extends Base { private String className = "Derived"; } public static void main(String[] args) { System.out.println(new Derived().className); } }

  1. Derived

  2. Compilation Error in Main mehod

  3. Compilation Error due to Derived class

  4. Run Time Error


Correct Option: B

What will be the output of the below code snippet? public class Quiz9 { public static void main(String args[]) { int j = 0; for (int i = 0; i < 100; i++) j++; System.out.println(j); } }

  1. 99

  2. 100

  3. 0

  4. 101


Correct Option: B

What will be the output of the below code snippet? public class Quiz10 { public static void main(String args[]) { System.out.println((int) (char) (byte) -1); } }

  1. 65536

  2. 65535

  3. 1

  4. -1


Correct Option: B

Given: 20. public class CreditCard { 21. 22. private String cardlD; 23. private Integer limit; 24. public String ownerName; 25. 26. public void setCardlnformation(String cardlD, 27. String ownerName, 28. Integer limit) { 29. this.cardlD = cardlD; 30. this.ownerName = ownerName; 31. this.limit = limit; 32. } 33. }

  1. The class is fully encapsulated.

  2. The code demonstrates polymorphism.

  3. The ownerName variable breaks encapsulation

  4. The cardlD and limit variables break polymorphism.


Correct Option: C

Which Man class properly represents the relationship “Man has a best friend who is a Dog”?

  1. class Man extends Dog { }

  2. class Man implements Dog { }

  3. class Man { private BestFriend dog; }

  4. class Man { private Dog bestFriend; }

  5. class Man { private Dog }

  6. class Man { private BestFriend }


Correct Option: D

Which statements about JDBC are true?

  1. JDBC is an API to connect to relational-, object- and XML data sources

  2. JDBC stands for Java DataBase Connectivity

  3. JDBC is an API to access relational databases, spreadsheets and flat files

  4. JDBC is an API to bridge the object-relational mismatch between OO programs and relational


Correct Option: B,C
- Hide questions