wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

JAVA PROGRAMMING

Total questions: 30

Worksheet time: 15mins

Name
Class
Date
1.

Here the class name is

(a)  

2.

memeber function name is

(a)  

3.

Select ALL subclasses

a)

Account

b)

Current

c)

Mortgage

d)

Bank

4.

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

a)

identifier

b)

keyword

c)

identifier & keyword

d)

none of the mentioned

5.

-OpeningDate

-InterestRate


are examples of what in OOP?

a)

Classes

b)

Objects

c)

Attributes / Properties

d)

Methods

6.

How do you call a method in Java?

a)

methodName();

b)

methodName[];

c)

(methodName);

d)

methodName;

7.

How do you create a method in Java?

a)

methodName()

b)

(methodName)

c)

methodName[]

d)

methodName.

8.

The value of a string variable can be surrounded by single quotes.

a)

true

b)

false

9.

Total number of primitive data types in Java are ....?

a)

5

b)

6

c)

7

d)

8

10.

Which method can be used to find the highest value of x and y?

a)

Math.largest(x,y)

b)

Math.max(x,y)

c)

Math.maximum(x,y)

d)

Math.maxNum(x,y)

11.

Command to compile Java program

a)

javax

b)

javay

c)

javac

d)

Java

12.

which is the legal range of values for a short?

a)

-128 to +127

b)

-255 to 255

c)

-32768 to 32767

d)

0 to 65535

13.

What does super keyword points to?

a)

Super Class

b)

Immediate parent class

c)

none

d)

Child class

14.

Which data type is used to create a variable that should store text?

a)

myString

b)

String

c)

Txt

d)

string

15.

Which of these operators is used to allocate memory to array variable in Java?

a)

malloc

b)

alloc

c)

new

d)

new malloc

16.

What will be the output of the given code?

a)

5 4

b)

4 5

c)

4 4

d)

5 5

17.

which declaration of the main() method is valid?

a)

public void main(String args[])

b)

public void static main(String args[])

c)

final public static void main(String []arr)

d)

public static void main(String []arr)

18.

Java was developed in which year

a)

1992

b)

1993

c)

1994

d)

1995

19.

What is the correct way to create an object called myObj of MyClass?

a)

new myObj = MyClass();

b)

class MyClass = new myObj();

c)

class myObj = new MyClass();

d)

MyClass myObj = new MyClass();

20.

Which of the following below resides in heap memory in java?

a)

class

b)

instance variable

c)

object

d)

method

21.

Java does not support.

a)

Multiple Inheritance

b)

Single Inheritance

c)

Multilevel Inheritance

d)

Hierarchical Inheritance

22.

Is 3*4 equivalent to 3 << 2 ?

a)

Yes

b)

NO

23.

Column size of a 2D array can be allocated separately!

a)

True

b)

False

24.

The size of the 'long' data type in bits is .....

a)

8-bit

b)

16-bit

c)

32-bit

d)

64-bit

25.

Which operator can be used to compare two values?

a)

==

b)

=

c)

<>

d)

><

26.

What will be the error in the following Java code?

byte b = 50;

b = b * 50;

a)

b cannot contain value 100, limited by its range

b)

* operator has converted b * 50 into int, which can not be converted to byte without casting

c)

b cannot contain value 50

d)

No error in this code

27.

What will be the result of given programme?

a)

Hello World!

b)

Infinite loop

c)

Compile-time error

d)

Run-time error

28.

Java programs ________________

a)

are only compiled

b)

are only compiled not interpreted

c)

are only interpreted

d)

are both compiled and interpreted

29.

Total number of primitive data types in Java are ....?

a)

5

b)

6

c)

7

d)

8

30.

In Java, it is possible to inherit attributes and methods from one class to another.

a)

True

b)

False