wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Java quiz-2024-Sec-B

Total questions: 12

Worksheet time: 10mins

Name
Class
Date
1.

USN

4 lines
2.

NAME

4 lines
3.

What will be the output of the code give below:

  class yes

{

public static void main(String[] args)

{

int Integer = 24;

char String  = 'I';

System.out.print(Integer);

System.out.print(String);

}}

a)

24I

b)

24

c)

Compiler error

d)

Runtime Error

4.

Which of the following is not a Java feature?

a)

Object-oriented

b)

Use of pointers

c)

Portable

d)

Dynamic and Extensible

5.

Java Implements Runtime Polymorphism through

a)

method overloading

b)

method overriding

c)

Dynamic method Dispatch

d)

none of the above

6.

is used to resolve name space collisions

a)

super

b)

object

c)

This

d)

all of the above

7.

What will be the output of the following code

public void method(double a)

{

System.out.println("Method called");

}

public static void main()

{ method(2);

}

a)

Method called

b)

compilation error

c)

runtime error

d)

none of the above

8.

Given that Student is a class, how many reference variables and objects are created by the following code?

  1. Student studentName, studentId;  

  2. studentName = new Student();  

  3. Student stud_class = new Student();  

a)
  1. Three reference variables and two objects are created.

b)
  1. Two reference variables and two objects are created.

c)
  1. One reference variable and two objects are created.

d)
  1. Three reference variables and three objects are created.

9.

Find the output of the following program.

public class Solution

{ public static void main(String[] args)

{

int[] x = {120, 200, 016};

for(int i = 0; i < x.length; i++)

{ System.out.print(x[i] + “ “);

}

}

}

a)

120 200 016

b)

120 200 14

c)

120 200 16

10.

When an array is passed to a method, what does the method receive?

a)

Length of the array

b)

copy of the array

c)

Reference of the array

d)

all of the above

11.

is the mechanism by which a call to overridden method is resolved at runtime

a)

method overloading

b)

Dynamic method dispatch

c)

method overriding

d)

method hiding

12.

Identify the corrected definition of a package.


a)

A package is a collection of editing tools

b)

A package is a collection of classes and interfaces

c)

A package is a collection of interfaces

d)

A package is a collection of classes