002_Java Methods

002_Java Methods

12th Grade

15 Qs

quiz-placeholder

Similar activities

Java Methods

Java Methods

University

15 Qs

OOP Java

OOP Java

12th Grade

20 Qs

FGCT4025 Topic 3 - Method

FGCT4025 Topic 3 - Method

University

15 Qs

Week 8

Week 8

12th Grade

13 Qs

CodeHS Classes & Objects

CodeHS Classes & Objects

9th - 12th Grade

10 Qs

Java

Java

9th - 12th Grade

10 Qs

Menus, Dialog Boxes and Methods

Menus, Dialog Boxes and Methods

10th Grade - Professional Development

17 Qs

C++ - Functions

C++ - Functions

University

14 Qs

002_Java Methods

002_Java Methods

Assessment

Quiz

Computers

12th Grade

Easy

Created by

Grit and Motivation

Used 1+ times

FREE Resource

15 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the return type of a method that does not return any value?

int

void

double

String

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is the correct syntax for defining a method in Java?

methodName returnType(parameters) { }

returnType methodName(parameters) { }

parameters methodName(returnType) { }

returnType(parameters) methodName { }

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following code snippet? ```java public class Calculator { public int addNumbers(int a, int b) { return a + b; } public static void main(String[] args) { Calculator calc = new Calculator(); int result = calc.addNumbers(5, 7); System.out.println("Sum: " + result); } } ```

Sum: 10

Sum: 12

Sum: 57

Sum: 0

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Identify the method type: `public void greet() { System.out.println("Hello, Welcome!"); }`

Method with Return Value

Method with Parameters

Method with No Return Value

Static Method

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following methods is an example of method overloading?

`public void display(int a) { }`

`public void display(String str) { }`

Both A and B

None of the above

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the purpose of method overloading in Java?

To increase the execution time of a program

To allow multiple methods with the same name but different parameters

To decrease the number of methods in a class

To make methods static

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Consider the method `public double square(double num) { return num * num; }`. What is the return type of this method?

int

void

double

float

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?