WorksheetsJava Method
Total questions: 25
Worksheet time: 15mins
Enter your name
What is method in java programming
way to code a program
block of code run by computer
block of code which only runs when it is called
instruction created in java
Why use methods
define the code once, and use it once
so our program looks clean
it is the only way to program
define the code once,and use it many times
Methods are also known as procedures
True
False
A method must be declared within a _____________.
variable
object
main
class
Method is defined with the name of the method, followed by parentheses ().
True
False
what is the name of the method?
AgeCalc
year
return
age
Which of the following represents a multi-line comment in Java?
<!-- Comment >
// Comment
/* Comment */
# Comment
Java will ignore the whitespace in code.
True
False
Which of the following represents a single line comment in Java?
/* Comment */
<!-- Comment -->
// Comment
# Comment
How many types of selection statement are there?
1
2
4
6
How many repetitive statements are there?
1
3
5
7
Which of the following is not type of variable for java programming?
local variable
instance variable
classic / static variable
import variable
Which one are not primitive data type for java?
int
double
byte
String
Num_Duo <- is this a valid identifier?
True
False
which repetitive statements will run once even if the condition is false?
If statement
For loop statement
Do.. while loop statement
While loop statement
The following expression will evaluate to what value?
System.out.println(5!=6)
True
5
6
False
What is the correct data type for the following variable:
__________ myAnswer = false;
String
char
int
boolean
byte, short, int, long, float, double, boolean and char are called __________ data types
primitive
variable
identifier
non-primitive
what is the meaning of the code below:
x++;
x = 1;
x = x + 1;
x = 2
Fill in the blank
(a)
Fill in the blank
(a)
Create an array of type String called cars.
String ________ = {"Volvo", "BMW", "Ford"};
cars
carsArray
cars[]
cars{}
Insert the missing part to call myMethod from main.
(a)
Which is the correct codes calling myMethod from main two times.
