Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Java Method

Total questions: 25

Worksheet time: 15mins

Name
Class
Date
1.

Enter your name

4 lines
2.

What is method in java programming

a)

way to code a program

b)

block of code run by computer

c)

block of code which only runs when it is called

d)

instruction created in java

3.

Why use methods

a)

define the code once, and use it once

b)

so our program looks clean

c)

it is the only way to program

d)

define the code once,and use it many times

4.

Methods are also known as procedures

a)

True

b)

False

5.

A method must be declared within a _____________.

a)

variable

b)

object

c)

main

d)

class

6.

Method is defined with the name of the method, followed by parentheses ().

a)

True

b)

False

7.

what is the name of the method?

a)

AgeCalc

b)

year

c)

return

d)

age

8.

Which of the following represents a multi-line comment in Java?

a)

<!-- Comment >

b)

// Comment

c)

/* Comment */

d)

# Comment

9.

Java will ignore the whitespace in code.

a)

True

b)

False

10.

Which of the following represents a single line comment in Java?

a)

/* Comment */

b)

<!-- Comment -->

c)

// Comment

d)

# Comment

11.

How many types of selection statement are there?

a)

1

b)

2

c)

4

d)

6

12.

How many repetitive statements are there?

a)

1

b)

3

c)

5

d)

7

13.

Which of the following is not type of variable for java programming?

a)

local variable

b)

instance variable

c)

classic / static variable

d)

import variable

14.

Which one are not primitive data type for java?

a)

int

b)

double

c)

byte

d)

String

15.

Num_Duo <- is this a valid identifier?

a)

True

b)

False

16.

which repetitive statements will run once even if the condition is false?

a)

If statement

b)

For loop statement

c)

Do.. while loop statement

d)

While loop statement

17.

The following expression will evaluate to what value?

System.out.println(5!=6)

a)

True

b)

5

c)

6

d)

False

18.

What is the correct data type for the following variable:


__________ myAnswer = false;

a)

String

b)

char

c)

int

d)

boolean

19.

byte, short, int, long, float, double, boolean and char are called __________ data types

a)

primitive

b)

variable

c)

identifier

d)

non-primitive

20.

what is the meaning of the code below:


x++;

a)

x = 1;

b)

x = x + 1;

c)

x = 2

21.

Fill in the blank

(a)  

22.

Fill in the blank

(a)  

23.

Create an array of type String called cars.

String ________ = {"Volvo", "BMW", "Ford"};

a)

cars

b)

carsArray

c)

cars[]

d)

cars{}

24.

Insert the missing part to call myMethod from main.

(a)  

25.

Which is the correct codes calling myMethod from main two times.

a)
b)
c)