Search Header Logo

Java Methods Quiz

Authored by Samar Sharkh

Computers

10th - 12th Grade

Used 211+ times

Java Methods Quiz
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

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

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?