Java Quiz

Java Quiz

Assessment

Quiz

Other

University

Hard

Created by

Harris onaeshim

FREE Resource

Student preview

quiz-placeholder

10 questions

Show all answers

1.

MULTIPLE SELECT QUESTION

3 mins • 2 pts

Who invented Java Programming?

Guido van Rossum

Dennis Ritchie

Bjarne Stroustrup

James Gosling

2.

MULTIPLE CHOICE QUESTION

3 mins • 2 pts

Which one of the following is not a Java feature?

Object-oriented

Dynamic and Extensible

Portable

Use of pointers

Answer explanation

Pointers is not a Java feature. Java provides an efficient abstraction layer for developing without using a pointer in Java. Features of Java Programming are Portable, Architectural Neutral, Object-Oriented, Robust, Secure, Dynamic and Extensible, etc.

3.

MULTIPLE CHOICE QUESTION

3 mins • 2 pts

Which of these cannot be used for a variable name in Java?

identifier & keyword

identifier

none of the mentioned

keyword

Answer explanation

Keywords are specially reserved words that can not be used for naming a user-defined variable, for example: class, int, for, etc.

4.

MULTIPLE CHOICE QUESTION

3 mins • 2 pts

What will be the output of the following Java code?

class increment {

public static void main(String args[])

{

int g = 3;

System.out.print(++g * 8);

}

}

32

33

25

24

Answer explanation

Operator ++ has more preference than *, thus g becomes 4 and when multiplied by 8 gives 32.
output:

5.

MULTIPLE CHOICE QUESTION

3 mins • 2 pts

  1. class output {

  2. public static void main(String args[])

  3. {

  4. double a, b,c;

  5. a = 3.0/0;

  6. b = 0/4.0;

  7. c=0/0.0;

  8.  

  9. System.out.println(a);

  10. System.out.println(b);

  11. System.out.println(c);

NaN

Infinity

0.0

all of the mentioned

Answer explanation

For floating point literals, we have constant value to represent (10/0.0) infinity either positive or negative and also have NaN (not a number for undefined like 0/0.0), but for the integral type, we don’t have any constant that’s why we get an arithmetic exception.

6.

MULTIPLE CHOICE QUESTION

3 mins • 2 pts

Which of the following is a type of polymorphism in Java Programming?

Multiple polymorphism

Compile Time Polymorphism

Mulitilevel Polymorphism

Execution time polymorphism

Answer explanation

There are two types of polymorphism in Java. Compile time polymorphism (overloading) and runtime polymorphism (overriding).

7.

MULTIPLE CHOICE QUESTION

3 mins • 2 pts

What will be the output of the following Java program?

  1. class leftshift_operator

  2. {

  3. public static void main(String args[])

  4. {

  5. byte x = 64;

  6. int i;

  7. byte y;

  8. i = x << 2;

  9. y = (byte) (x << 2);

  10. System.out.print(i + " " + y);

0 256

256 0

0 64

64 0

Answer explanation

Answer: c
Explanation: None.
output:

$ javac leftshift_operator.java $ java leftshift_operator 256 0

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?