Java Methods Quiz

Java Methods Quiz

Assessment

Quiz

Computers

10th - 12th Grade

Easy

Created by

Samar Sharkh

Used 207+ times

FREE Resource

Student preview

quiz-placeholder

5 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is the correct syntax for writing a method with parameters?

public static void example(x: int, y: int) {}

public static void example(x, y) {}

public static void example(int x, int y) {}

public static void example(int x,y) {}

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

What output is produced by the following program?

"15 42"

"10 25"

"57"

"25"

57

25

"num1 num2"

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Why do we use methods in Java programming?

Break down our program into smaller parts

Avoid repeating code

Make our program more readable

All of the above

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What are parameters?

The value that a method returns.

The values that a method prints to the screen.

The type that is given to a variable.

The formal names given to the data/variables that are passed into a method.

5.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

What is the output of the code below?


public class ExampleVoid {


public static void main(String[] args) {

methodRankPoints(255.7);

}


public static void methodRankPoints(double points) {

if (points >= 202.5) {

System.out.println("Rank:A1");

}else if (points >= 122.4) {

System.out.println("Rank:A2");

}else {

System.out.println("Rank:A3");

}

}

}

Rank:A1

Rank:A2

Rank:A3

No output