0
Alien head

programming languages Online Quiz - 18

Description: programming languages Online Quiz - 18
Number of Questions: 20
Created by:
Tags: programming languages

Which of the following is not a C# keyword?

  1. a. if

  2. b. implements

  3. c. private

  4. d. delegates

Answer: 2

Setter is a special method, that sets property value. Used for private or protected variables or for some additional validation

  1. True

  2. False

Answer: 1

What was the first language to bring together all the features that characterize an object-oriented programming system?

  1. C++

  2. Java

  3. SmallTalk

  4. C

Answer: 3

Overloading, overriding and dynamic method binding are three types of what?

  1. Inheritance

  2. Polymorphism

  3. Generalization

  4. Abstraction

Answer: 2

Which class is the highest superclass of Java?

  1. root

  2. object

  3. stem

  4. minor

Answer: 2

What is the name for an application changing a readable programming language into a machine-readable language?

  1. Encoder

  2. Converter

  3. Compiler

  4. Translator

Answer: 3

Short-circuit parameters are && and ||

  1. True

  2. False

Answer: 1

String strA; String strB = new String("Cheese"); How many objects have been created in the above code snippet?

  1. 3

  2. 1

  3. 2

  4. 0

Answer: 2

What is another name for creating an object?

  1. initialization

  2. instantiation

  3. inheritance

  4. insubordination

Answer: 2

What attributes do all real world objects have?

  1. size and weight

  2. identity, state, and behavior

  3. state and behavior

  4. height and shape

Answer: 2

What is the result of trying to compile and run the following code. public static void main(String[] args){ double d = 10 / 0; if(d == Double.POSITIVE_INFINITY) System.out.println("Positive infinity"); else System.out.println("Negative infinity"); }

  1. output Positive infinity

  2. output Negative infinity

  3. Will fail to compile

  4. Runtime exception

Answer: 4

Identify the invalid assignments.

  1. float f = \u0038;

  2. long L2 = 2L;

  3. float f = 1.2;

  4. char c = '/u004E';

  5. byte b = 100;

Answer: 3

The range of a byte is from -127 to 128.

  1. True

  2. False

Answer: 2

The following code is legal? long longArr[]; int intArr[] = { 7 ,8 , 9}; longArr = intArr;

  1. True

  2. False

Answer: 2

What will happen if you try to compile and run this ? public class Test{ static{ print(10); } static void print(int x){ System.out.println(x); System.exit(0); } }

  1. Compiler error.

  2. Will throw a NoSuchMethod error at runtime.

  3. It will compile and run printing out "10"

  4. It will run with no output.

  5. It will run and print "10" and then crash with an error.

Answer: 3

What is the result of trying to compile and run this program. public class Test{ public static void main(String[] args){ int[] a = {1}; Test t = new Test(); t.increment(a); System.out.println(a[a.length - 1]); } void increment(int[] i){ i[i.length - 1]++; } }

  1. Compiler error.

  2. Compiles and runs printing out 2

  3. Compiles and runs printing out 1

  4. An ArrayIndexOutOfBounds Exception at runtime

Answer: 2

Which of the following are valid declarations?

  1. int i = 0XCAFE;

  2. boolean b = 0;

  3. char c = A;

  4. byte b = 128;

  5. char c = "A";

Answer: 1

What is the result that will be printed out ? void aMethod() { float f = (1 / 4) * 10; int i = Math.round(f); System.out.println(i); }

  1. 2

  2. 0

  3. 3

  4. 2.5

  5. 25

Answer: 2

What is the result of trying to compile and run the following code. public final static void main(String[] args){ double d = 10.0 / -0; if(d == Double.POSITIVE_INFINITY) System.out.println("Positive infinity"); else System.out.println("Negative infinity"); }

  1. output Positive infinity

  2. output Negative infinity

  3. Will fail to compile

  4. Runtime exception

Answer: 1

You have the following code in a file called Test.java class Base{ public static void main(String[] args){ System.out.println("Hello"); } } public class Test extends Base{} What will happen if you try to compile and run this?

  1. It will fail to compile.

  2. Runtime error

  3. Compiles and runs with no output.

  4. Compiles and runs printing "Hello"

Answer: 4
+ View questions