wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Java

Total questions: 60

Worksheet time: 20mins

Name
Class
Date
1.

Java

programming is a ----------------

a)

Structure

oriented programming

b)

Object

oriented programming

c)

a &

b

d)

none of

the above0

2.

In object-oriented programming, the process

by which one object acquires the properties of another obje

a)

Encapsulation

b)

Polymorphism

c)

Inheritance

d)

Dynamic

binding

3.

What is

object?

a)

Data & Methods

b)

Data & object

c)

Data & class

d)

none of

the above

4.

Object may be communicate --------------

a)

Through object

b)

Through class

c)

Through methods

d)

Through

data

5.

Java program Implements ---------------

design approach

a)

Top-up approach

b)

bottom-up approach

c)

a & b

d)

none of

the above

6.

Consider

the following Java program :

public class Compute {

public static void main (string args [ ])

{

int result, x ;

x = 1 ;

result = 0;

while (x < = 10) {

if (x%2 == 0) result + = x ;

+ + x ;

}

System.out.println(result) ;

}

}

Which of the following will be the output of the above program?

a)

55

b)

30

c)

25

d)

35

7.

Data

Abstraction and Encapsulation is for --------------------

a)

Data & objects

b)

Data & Methods

c)

Data Class

d)

Data

& concepts

8.

Dynamic

Binding binds------------.

a)

Procedure methods

b)

Procedure class

c)

Procedure objects

d)

Procedure

calls

9.

Java

Message communication can support -----------------

a)

Sending

b)

Receiving

c)

a & b

d)

none of

the above

10.

What is

application of OOP?

a)

Real time system

b)

Object oriented data base

c)

CAD system

d)

all of

the above

11.

Which of

the following variable declaration would NOT compile in a java program?

a)

int

var;

b)

int VAR;

c)

int var1;

d)

int

1_var;.

12.

The java

does not include ------------

a)

variables

b)

operators

c)

methods

d)

Global

variable

13.

Which

one is java token?

a)

Identifiers

b)

Operators

c)

Literals

d)

all the

above

14.

What is

Literal?

a)

Characters

b)

methods

c)

class

d)

object

15.

Java

compiler javac translates Java source code into ………………………

a)

Assembler

language

b)

Byte

code

c)

Machine

code

d)

Bit

code

16.

Which is

not operator?

a)

Pointer

b)

arithmetic

c)

special

d)

bitwise

17.

What

will be printed as the output of the following program?

public class testincr

{

public static void main(String args[])

{

int i = 0;

i = i++ + i;

System.out.println(“I = ” +i);

}

}

a)

I=0

b)

I=1

c)

I=2

d)

Error

18.

Which is

one of the relational operators?

a)

<

b)

>

c)

==

d)

all of the above

19.

The

operator who also acts as a string concatenation _______

a)

a)

/

b)

b) *

c)

c)

+

d)

d) –

20.

What is the type and value of the following expression? (Notice the integer

division)

-4 + 1/2 + 2*-3 + 5.0

a)

int -5

b)

double

-4.5

c)

int

-4

d)

double

-5.0

21.

Literals

also called as____

a)

Keywords

b)

Constants

c)

Identifiers

d)

Operators

22.

Java

supports two selection statements that are ____________ and __________

a)

If and

Jump

b)

If and

Switch

c)

If and

while

d)

If and

For

23.

______ repeats a statement or block while

its controlling expression is true

a)

jump

b)

do-while

c)

while

d)

for

24.

Use the

following declaration and initialization to evaluate the Java

expressions

int a = 2, b = 3, c = 4, d = 5;

float k = 4.3f;

System.out.println (c=c++);

a)

2

b)

4

c)

5

d)

8

25.

Predict

the output of following Java Programs.

// filename Main.java

class Test {

protected int x, y;

}

class Main {

public static void main(String

args[]) {

Test t = new Test();

System.out.println(t.x +

" " + t.y);

}

}

a)

1,1

b)

1,2

c)

0,0

d)

Error

26.

What is

arithmetic Expressions?

a)

variables

b)

constants

c)

operator

d)

all of the above

27.

What is

casting a value?

a)

expression

b)

ratio

c)

operator

d)

all of the above

28.

Consider the following Java program :

class IfStatement{

public static void main(String args[])

{

int a=2, b=3;

if (a==3)

if (b==3)

System.out.println(“===============”);

else

System.out.println(“#################”);

System.out.println(“&&&&&&&&&&&”);

}

}

Which of the following will the output be?

a)

===============

b)

#################

&&&&&&&&&

c)

&&&&&&&&&&&

d)

===============

#################

29.

Syntax

of the class variables________

a)

Class_name.class_variables

b)

public

static void main (String arg [])

c)

Class_name

object_name;

d)

Class

name_anyRef;

30.

Non-primitive

data type is ______

a)

Array

b)

interface

c)

Class

d)

all of the above

31.

The

general form of constructing an array is _______

a)

Datatype

arr-name [];

b)

Datatype

[]arr-name;

c)

arr-name=

new datatype[noOfElements];

d)

arr-name.length

32.

Which is

one of the symbol of array?

a)

{ }

b)

( )

c)

[ ]

d)

< >

33.

Strings

represent a sequence of _____________

a)

Variable

b)

Character

c)

Data type

d)

All the above

34.

Consider

the following class definition:

public class MyClass

{

private int value;

public void setValue(int i){ / code / }

// Other methods…

}

The method setValue assigns the value of i to the instance field value.

What could you write for the implementation of setValue?

a)

value = i;

b)

this.value = i;

c)

value == i;

d)

Both

(A) and (B) and above

35.

JAVA

does not directly implement____________

a)

Multiple

inheritance

b)

Multilevel inheritance

c)

Hybrid inheritance

d)

Single inheritance

36.

An

interface is basically a kind of

a)

Method

b)

Class

c)

Object

d)

Keyboard

37.

What is

a keyword used in extending interfaces?

a)

Extern

b)

Extend

c)

Extnd

d)

extends

38.

The

interface item would inherit both the

constants-----------------------and---------------------

a)

Code, Variable

b)

Code, Name

c)

Code, Method

d)

Extends

39.

Predict

the output of following Java programs.

package main;

class Base {

public void Print() {

System.out.println("Base"); }

}

class Derived extends Base {

public void Print() {

System.out.println("Derived");

} }

class Main{

public static void DoPrint( Base

o ) {

o.Print();

}

public static void main(String[]

args)

{ Base x = new Base();

Base y = new Derived();

Derived z = new Derived();

DoPrint(x);

DoPrint(y);

DoPrint(z);

} }

a)

Base,

Derived, Derived

b)

Derived,

Derived ,Derived

c)

Derived,

Derived, Base

d)

None

40.

In

Inheritance the old class is known as__________

a)

Base class

b)

Semi class

c)

derived class

d)

Semi super class

41.

What is

a package?

a)

Varity of classes

b)

Varity of interfaces

c)

a & b

d)

None of these

42.

Expand

API

a)

Application

programming interface

b)

Advanced programming interface

c)

Architecture programming interface

d)

Artificial programming interface

43.

Multithreading

concept can be divided into _________

a)

Class

b)

Processes

c)

Method

d)

Object

44.

How to

create a thread in initial stage

a)

Over()

b)

Start()

c)

Run()

d)

Stop()

45.

How to

block the thread exceptions

a)

Sleep()

b)

Start()

c)

Stop()

d)

Run()

46.

Applet

program are used to the ----------------

a)

Internet computing

b)

Cloud Computing

c)

Grid Computing

d)

Green Computing

47.

An

applet developed by ---------------

a)

Server applet

b)

Client Applet

c)

Local Applet

d)

None of the above

48.

Which is

the applet tag?

a)

<APPLET<

b)

<APPLET>

c)

<APPLET?

d)

(APPLET)

49.

The

applet class which is contained in the ----------------package.

a)

java.applet

b)

java,applet

c)

java/applet

d)

java\applet

50.

The

Graphics object g is an argument of -------------------------

a)

point()

b)

pint()

c)

pant()

d)

paint()

51.

which is

one of the initialization state?

a)

int()

b)

init()

c)

initial()

d)

inti()

52.

which is

one of the dead state?

a)

start()

b)

stop()

c)

destroy()

d)

dead()

53.

which is

one of the display state?

a)

start()

b)

stop()

c)

point()

d)

paint()

54.

what is

the executable applet?

a)

.class

b)

.object

c)

.method

d)

.function

55.

What is

the concept of web page?

a)

xml

b)

xds

c)

html

d)

none of the above

56.

How to

write the comment line in web page ?

a)

<!...>

b)

<?>

c)

<*>

d)

<&>

57.

When the

applet is terminated _________and________ methods are called sequence

a)

run()

and destroy()

b)

stop()

and destroy()

c)

run()

and stop()

d)

none

58.

The

graphics object requires-------------------------

a)

paint()

b)

pont()

c)

math()

d)

point()

59.

what is

the purpose of for loops in applet?

a)

circles

b)

triangle

c)

rectangle

d)

square

60.

which is

used for graphics object?

a)

<g>

b)

(g)

c)

g.

d)

,g