wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Java

Total questions: 69

Worksheet time: 35mins

Name
Class
Date
1.

Java was originally named:

a)

Coffee

b)

Oak

c)

New C++

d)

Duke

2.

From where did Java get its name?

a)

Coffee

b)

Book

c)

TV Programme

d)

Initials of the developers of Java

3.

Is Android based on Java?

a)

True

b)

False

4.

When was Java released?

a)

1975

b)

1985

c)

1995

d)

2005

e)

2015

5.

Who invented Java?

a)

James Gosling

b)

Sergey Brin

c)

Steve Jobs

d)

Bill Gates

e)

Tim Berners-Lee

6.

What is the name of the Java mascot?

a)

Duke

b)

Ronny

c)

Penguin

d)

James

e)

Jack

7.

How many Java developers are there?

a)

1 million

b)

5 million

c)

10 million

d)

20 million

8.

What was Java originally designed for?

a)

Interactive TV

b)

Internet

c)

Gaming

d)

Cars

9.

Which company owns Java?

a)

Oracle

b)

Microsoft

c)

Google

d)

Apple

e)

Intel

10.

which of the following is wrapper class in java

a)

Float

b)

Integer

c)

Double

d)

all of above

11.

which one this keywords are used to create a class in java

a)

class

b)

struct

c)

int

d)

none of the avove

12.

which one of these events will cause the thread to die?

a)

on calling the sleep() method.

b)

when the execution of the run() method ends

c)

when the execution of the start() method ends

d)

on calling the wait() method

13.
Which type of data is used to enter the value (1234.5)?
a)
Integer
b)
Double 
c)
Char
d)
Void
14.
Which type of data is used to enter the value ("Welcome")?
a)
Text
b)
Characters
c)
String
d)
Boolean
15.
Which type of data is used to enter the value (True)?
a)
Float
b)
Boolean
c)
Check box
d)
ٍString
16.
We are use Scanner Library in java for...
a)
Give permissions to the user
b)
Correcting software errors
c)
Allows user to read data
d)
Allows the user to enter data
17.
We are use Random Library in java for...
a)
Choose a set of random numbers
b)
Deploy the program randomly
c)
Store a set of information at random
d)
All answers are correct
18.
We are use For loop ..........
a)
To repeat a specified number of operations.
b)
To repeat a unspecified number of operations.
c)
All answers are correct
19.
We are use While loop ..........
a)
To repeat a specified number of operations.
b)
To repeat a unspecified number of operations.
c)
All answers are correct
20.
When we want to print in Java, we use the code ......
a)
system.out.print();
b)
System.out.println();
c)
System.Out.Printf();
d)
System.out.show();
21.

_________ operator returns the remainder after division

a)

+

b)

/

c)

%

d)

*

22.

________ operator is used to check the equality of two values

a)

>=

b)

=

c)

*=

d)

==

23.

Bit wise operations only carried out only in integer /long integer values.

a)

True

b)

False

24.

Operator used to access the members of a class /package

a)

(.) Dot

b)

(,) Comma

25.

Java has goto statement

a)

True

b)

False

26.

Java doesn't support structures and unions

a)

True

b)

False

27.

Java is

a)

platform dependent

b)

platform indeprndent

28.

In Java WORA stands for

a)

Write Once Recall Anywhere

b)

Write Once Return Anywhere

c)

Write Once Read Anywhere

d)

Write Once Run Anywhere

29.

JVM stands for

a)

Java Vital Machine

b)

Java Virtual Machine

c)

Java Vendor machine

30.

Java programs ________________

a)

are only compiled

b)

are only compiled not interpreted

c)

are only interpreted

d)

are both compiled and interpreted

31.

In Java, execution starts from ___________ function.

a)

get()

b)

main()

c)

java()

d)

display()

32.

Main() method is not mandatory for a Java program

a)

True

b)

False

33.

++ increases the value of a variable by 1

a)

assignment operator

b)

decrement operator

c)

increment operator

d)

sentinel

34.

What would the new value of A be?

A=1;

a++;

a)

1

b)

2

c)

3

d)

4

35.

What's the value of below?


int i=5;

System.out.println(i++);

System.out.println(i);

System.out.println(++i);

a)

5

6

7

b)

6

6

7

c)

6

7

8

d)

5

5

6

36.

Which statement(s) are equivalent to i = i + 1?

a)

i += 1

b)

i++

c)

i -= 1

d)

i--

37.

Which are the types of operators seen? Select as many you think

a)

bitwise operator

b)

subtraction operator

c)

equality operator

d)

arithmetic operator

38.

what is modulo operation used for ?

a)

performs division

b)

performs division and gives no remainder

c)

performs division and gives remainder

d)

does not perform division

39.

arithmetic operators return a value. True or false?

a)

true

b)

false

40.

conditional operators does not return a value

a)

true

b)

false

41.

which data types work on bitwise operators?

a)

byte

b)

double

c)

char

d)

int

42.

which type of operator it is? i + =5

a)

addition assignment operator

b)

conditional operator

c)

arithmetic operator

d)

equality operator

43.

Find the output for the following.

public class IncDec

{

public static void main(String s[])

{

int a = 1;

int b = 2;

int c;

int d;


c = ++b;

d = a++;


c++;


System.out.println("a = " + a);

System.out.print("b = " + b);

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

System.out.print("d = " + d);

}

}

a)

a = 2 b = 3 c = 4 d = 1

b)

a = 2 b = 3 c = 4 d = 1

c)

Program does not compile.

d)

a = 1 b = 2 c = 4 d = 2

44.

What will be the output of the program?

class Test

{

public static void main(String [] args)

{

int x=20;

String sup = (x < 15) ? "small" : (x < 22)? "tiny" : "huge";

System.out.println(sup);

}

}

a)

small

b)

tiny

c)

huge

d)

Compilation fails

45.

Find the output of the following snippet.


class Numbers

{

public static void main(String args[])

{

int a=20, b=10;

if((a<b)&&(b++ <25))

{

System.out.println("this is any language logic");

}

System.out.println(b);

}

}

a)

10

b)

12

c)

11

d)

Compilation Error

46.

Please write correct output in following space-

a)

10

b)

20

c)

No Output

d)

Error

47.
A variable that holds a whole number
a)
String
b)
boolean
c)
int
d)
float
48.

A variable that holds words

a)

String

b)

boolean

c)

int

d)

float

e)

A dictionary

49.

A variable that holds true or false

a)

String

b)

boolean

c)

int

d)

float

e)

Alex Trebek

50.

Name the data type: 1.0

a)

double

b)

int

c)

char

d)

boolean

51.

Name the data type: "true"

a)

boolean

b)

char

c)

String

d)

double

52.

Name the data type: false

a)

String

b)

boolean

c)

int

d)

None of the above

53.

What data type would you use for storing the number of students in a class?

a)

boolean

b)

String

c)

double

d)

int

54.

What data type would you use for storing the average test score in a class?

a)

double

b)

String

c)

int

d)

char

55.

What data type would you use to store names of students?

a)

String

b)

char

c)

boolean

d)

None of these

e)

blonde

56.

How would you declare a variable storing the tax rate?

a)

int taxRate = 5.1;

b)

taxRate = "5.1";

c)

double taxRate = 5.1;

d)

double taxRate = "5.1";

e)

I do hereby declare thee Sir Tax Rate

57.

How would you declare a variable storing a person's name?

a)

string name = "Elroy";

b)

name String = "Elroy";

c)

String name = Elroy;

d)

String name = "Elroy";

e)

Me llamo Elroy

58.

How would you declare a variable that tells you that someone passed a class?

a)

boolean passed = 'true';

b)

boolean passed = true;

c)

passed = true;

d)

String passed = "true";

e)

Trick question - no one passes this class

59.

Which declaration will throw an error?

a)

double num = 8;

b)

int averageGrade = 89.7;

c)

boolean done = false;

d)

String done = "true";

60.

What prints out "I love Java" successfully?

a)

System.out.println(I love Java);

b)

Systemoutprintln("I love Java);

c)

System.out.println("I love" + " Java");

d)

System.out.println("I love Java")

e)

What is love? Baby dont hurt me. Dont hurt me. No more.

61.

Describe method.

a)

A component of a program in a big program.

b)

A program to perform a specific task.

c)

A component of a program written to perform a specific task.

d)

A variable that use to read an input.

62.

This is an example of a non-return method.

a)

True

b)

False

63.

Method make codes more readable and easier to debug.

a)

True

b)

False

64.

The name of this method is ....

a)

Oddsum

b)

int Oddsum

c)

int Oddsum (int number)

d)

return totaloddsum

65.

The different between static and non static method is ....

a)

for non static method : user need to create object in a class to call a method.

b)

A method is to perform only specific task.

c)

There is no significant differences between static and non - static method.

d)

Both are bounded with a class.

66.

Data type for non return method is

a)

int

b)

double

c)

void

d)

public static

67.

Which one of the following is escape sequences?

a)

\r

b)

\n

c)

\f

d)

\t

68.

Int data types represents _______ bits.

a)

8

b)

16

c)

32

d)

64

69.

Enter your Reg No

4 lines