Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Topic 3 : Java Language

Total questions: 35

Worksheet time: 18mins

Name
Class
Date
1.

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

a)

class

b)

struct

c)

int

d)

none of the avove

2.
Which type of data is used to enter the value ("Welcome")?
a)
Text
b)
Characters
c)
String
d)
Boolean
3.
Which type of data is used to enter the value (1234.5)?
a)
Integer
b)
Double 
c)
Char
d)
Void
4.
Which type of data is used to enter the value (True)?
a)
Float
b)
Boolean
c)
Check box
d)
ٍString
5.
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
6.
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
7.
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
8.
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();
9.

What would the new value of A be?

A=1;

a++;

a)

1

b)

2

c)

3

d)

4

10.

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

a)

i += 1

b)

i++

c)

i -= 1

d)

i--

11.

What symbol represents the and operator in Java?

a)

AND

b)

and

c)

&

d)

&&

12.

What symbol represents the or operator in Java?

a)

OR

b)

or

c)

||

d)

|

13.
Which one of the following is NOT a logical operator?
a)
||
b)
&&
c)
$$
d)
!
14.

If a=2, b=5, c=3

Find result for : 8 * (a + b + c) – a % c

a)

80

b)

81

c)

77

d)

78

15.

int a = 2, b = 2, c = 0;

double d = 30.1;


Find answer for = (a > b) &&(( c <d) || (c!=a))

a)

35.9

b)

80

c)

true

d)

false

16.

What index value is used to locate the last element in the nums ArrayList?

a)

nums.size()-1

b)

nums.length()-1

c)

nums.size()

d)

nums.length

17.

This expression executes at the end of each iteration of the for loop.

a)

a. initialization expression

b)

b. test expression

c)

c. update expression

d)

d. statement block

18.

This expression is executed by the for loop only once, regardless of the number of iterations.

a)

a. initialization expression

b)

b. test expression

c)

c. update expression

d)

d. preincrement expression

19.

List all arguments that exist in this program segment:-

a)

double point, String student

b)

point, student

c)

name, mark

d)

name[i], mark[i]

20.

List all parameters that exist in this program segment:-

a)

double point, String student

b)

point, student

c)

name, mark

d)

name[i], mark[i]

21.

Identify the error that exist in this program segment:-

a)

An array data type cannot be use as argument.

b)

The argument was not in the right sequence with the parameter.

c)

The variable name in parameter not as same with the argument.

d)

Program consist 0 error.

22.

Identify the object that used to call a method.

a)

Status

b)

name[i], mark[i]

c)

mtd

d)

void

23.

Fix the error by replacing with the correct java statement.

a)

void Status(String student, double point)

b)

void Status ( name[i], mark[i] )

c)

int Status(String student, double point)

d)

void Status ( String name[i], double mark[i] )

24.

Create a method name Bonus that will read a basic payment and an hour variable as parameter to calculate an extra salary.

a)
b)
c)
d)
25.

Identify the error that exist in this method program:-

a)

Wrong use of return method type

b)

variable extra was unknown.

c)

doble is not one of the data type

d)

A wrong use of hour data type.

26.

Identify the error that exist in this method program:-

a)

Wrong use of return method type

b)

variable extra was unknown.

c)

doble is not one of the data type

d)

A wrong use of hour data type.

27.

Identify types of error that exist in this method program:-

a)

Logic error

b)

runtime error

c)

syntax error

28.

Why method is important?

a)

Break program into a small program and easy to debug.

b)

Easier to read and understand aspecially when involving with a big program.

c)

More practical when we need to reuse the code.

d)

Can store more similar values in a single variable.

29.

Java is a

a)

Procedure Oriented Language

b)

Structure Oriented Language

c)

Object_Oriented Language

d)

Machine Language

30.

The name of the following should be the file name in Java

a)

Object Name

b)

Variable Nam

c)

Class Name

d)

Array Name

31.

Java program does not run without below function

a)

user()

b)

system()

c)

main()

d)

void()

32.

Java is

a)

Machine dependent language

b)

Machine independent language

33.
What does polymorphism mean?
a)
Changing shapes
b)
Having many forms
c)
Being unchangeable
d)
Easy
34.
In Java, each child class can have only one parent.
a)
True
b)
False
35.

Which of the following statements is invalid?

a)

Tutor jimmy = new CSTutor();

b)

CSTutor sally = new JavaTutor();

c)

Tutor suzie = new JavaTutor();

d)

Tutor johnny = new Tutor();