0

programming languages Online Quiz - 77

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

Who is the loose character in java??

  1. class

  2. interface

  3. package

  4. data type


Correct Option: B

JAVA 1.4 introduced the concept of Generics?

  1. True

  2. False


Correct Option: B

PHP is a client- side scripting language?

  1. True

  2. False


Correct Option: B

PHP stands for?

  1. Pre Hypertext Processor

  2. Preprocessor Hypertext

  3. Hypertext Preprocessor

  4. Processor Hypertext Pre


Correct Option: C

PHP is a loosely typed language?

  1. True

  2. False


Correct Option: A

Which are two statements for outputing the text in PHP?

  1. print and display

  2. display and echo

  3. println and display

  4. echo and print


Correct Option: D

Following code will result in: int a = 3.5;

  1. Compilation error

  2. Runtime error

  3. a being 3.5

  4. a being 3


Correct Option: A

Following code will result in: int a1 = 5; double a2 = (float)a1;

  1. Compilation error

  2. Runtime error

  3. Runtime exception

  4. No error


Correct Option: D

AI Explanation

To answer this question, let's go through each option to understand why it is correct or incorrect:

Option A) Compilation error - This option is incorrect. The given code will not result in a compilation error because it follows valid syntax. The code initializes an integer variable a1 with the value 5 and then assigns its value to a double variable a2 after performing a type cast.

Option B) Runtime error - This option is incorrect. The given code will not result in a runtime error because there is no invalid operation or division by zero involved. The code simply performs a type cast from an integer to a double.

Option C) Runtime exception - This option is incorrect. The given code will not result in a runtime exception because there is no exceptional condition or error that would cause the program to terminate abruptly.

Option D) No error - This option is correct. The given code will execute without any error. It initializes an integer variable a1 with the value 5 and then assigns its value to a double variable a2 after performing a type cast.

The correct answer is D. No error. This option is correct because the code will compile and execute without any errors or exceptions.

Following code will result in: int a = 9/0;

  1. Compilation error: Divisions must be in a try block.

  2. Compilation error: DivideByZeroException

  3. Runtime Exception - correct answer

  4. No Error: a is NaN


Correct Option: C

Following code will result in: float a = 9/0;

  1. Compilation error: Divisions must be in a try block

  2. Compilation error: DivideByZeroException

  3. Runtime Exception

  4. No Error: a is NaN


Correct Option: D

AI Explanation

To answer this question, let's go through each option to understand why it is correct or incorrect:

Option A) Compilation error: Divisions must be in a try block - This option is incorrect. Divisions do not need to be in a try block. A try block is only necessary when there is a possibility of an exception being thrown.

Option B) Compilation error: DivideByZeroException - This option is incorrect. Although dividing by zero is an error, the code will compile without any issues.

Option C) Runtime Exception - This option is incorrect. The code will not throw a runtime exception.

Option D) No Error: a is NaN - This option is correct. When dividing any number by zero in Java, the result is not a number (NaN).

The correct answer is D. No Error: a is NaN. This option is correct because dividing by zero in Java results in NaN (Not a Number) without any compilation or runtime errors.

Following code will result in: class A { int b = 1; public static void main(String [] args) { System.out.println("b is " + b); }}

  1. Compilation error

  2. Runtime Error

  3. Runtime Exception

  4. Output of b is 1


Correct Option: A

Following code will result in: class A { public static void main(String [] args) {B b = new A(); }} class B extends A {}

  1. Compile error

  2. Runtime Exception

  3. No error

  4. Rintime Error


Correct Option: A

Following code will result in: class A { public static void main(String [] args) {A a = new B(); }} class B extends A {}

  1. Compiler error

  2. Runtime Exception

  3. No errors

  4. Runtime Error


Correct Option: C

AI Explanation

To answer this question, let's analyze the given code:

class A {
    public static void main(String[] args) {
        A a = new B();
    }
}

class B extends A {}

In the code, a class A is defined with a main method. Inside the main method, an object a of type A is created using the constructor of class B. Class B is a subclass of A.

Since class B extends class A, it is considered to be a subtype of A. Therefore, it is valid to assign an instance of B to a variable of type A. This is known as polymorphism in Java.

Hence, there are no errors in the given code, and the correct answer is C) No errors.

If class A implements an interface does it need to implement all methods of that interface?

  1. Yes, always it should implement

  2. No, Never

  3. No, Not when A is abstract

  4. None of the above


Correct Option: C

The methods wait(), notify() and notifyAll() in Object need to be called from synchronized pieces of code.

  1. true

  2. false

  3. Depends on situation

  4. none of the above


Correct Option: B

A class cannot be declared

  1. volatile

  2. private

  3. default

  4. static


Correct Option: B

mainn() { main(); } This loop runs upto???

  1. Infinite loop

  2. Until Stack Underflow

  3. Until Machine Hangs

  4. Stack Overflow


Correct Option: D

Complexity of Quick Sort????(avg)

  1. O(n2)

  2. O(log n)

  3. O(nlogn)

  4. O(n2 logn)


Correct Option: C

Complexity Of Bubble Sort..???

  1. O(n)

  2. O(log n)

  3. O(n^2)

  4. O(n log n)


Correct Option: C

What is the difference between the types double and Double?

  1. double is primitive datatypes. Double is a class

  2. Both are primitive dataType

  3. Both are class type

  4. double is class and Double is primitive Type


Correct Option: A
- Hide questions