Java methods

Java methods

9th - 12th Grade

15 Qs

quiz-placeholder

Similar activities

Csharp 1.

Csharp 1.

12th Grade

16 Qs

Quiz Java 1

Quiz Java 1

10th Grade

10 Qs

APCS Printing and objects

APCS Printing and objects

9th Grade - University

10 Qs

Recursion in Java (AP Computer Science A)

Recursion in Java (AP Computer Science A)

9th - 12th Grade

10 Qs

Methoden

Methoden

10th - 11th Grade

10 Qs

APCSU1D5 Compound Assignments

APCSU1D5 Compound Assignments

12th Grade

10 Qs

Sains Komputer (Java) 1: Sintaks Asas & Pembolehubah

Sains Komputer (Java) 1: Sintaks Asas & Pembolehubah

10th Grade - University

10 Qs

Unit 10 Recursion Review

Unit 10 Recursion Review

9th - 12th Grade

20 Qs

Java methods

Java methods

Assessment

Quiz

Computers

9th - 12th Grade

Easy

Created by

Mike Skramstad

Used 4+ times

FREE Resource

15 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

Create a Java function called mystery that takes two Strings and returns a String.

public String mystery(String str1, String str2) { // function body }
public String mystery(String str) { // function body }
public String mystery(int num1, int num2) { // function body }
public void mystery(String str1, String str2) { // function body }

2.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

Write a Java method named calculateSum that takes two integers and returns their sum as an integer.

public int calculateSum(int num1, int num2) { // method body }

public void calculateSum(int num1, int num2) { // method body }

public int calculateSum(double num1, double num2) { // method body }

public double calculateSum(int num1, int num2) { // method body }

3.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

Define a Java method called isEven that takes an integer and returns a boolean indicating whether the number is even.

public boolean isEven(int number) { // method body }

public int isEven(int number) { // method body }

public void isEven(int number) { // method body }

public boolean isEven(double number) { // method body }

4.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

Implement a Java function named concatenateStrings that takes two strings and returns their concatenation.

public String concatenateStrings(String str1, String str2) { // function body }

public void concatenateStrings(String str1, String str2) { // function body }

public String concatenateStrings(String str) { // function body }

public int concatenateStrings(String str1, String str2) { // function body }

5.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

Develop a Java method named findMaximum that takes two integers and returns the larger of the two.

public int findMaximum(int num1, int num2) { // method body }

public void findMaximum(int num1, int num2) { // method body }

public double findMaximum(double num1, double num2) { // method body }

public int findMaximum(int num) { // method body }

6.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

Write a Java function called reverseString that takes a string as input and returns the string in reverse order.

public String reverseString(String str) { // function body }

public void reverseString(String str) { // function body }

public String reverseString() { // function body }

public int reverseString(String str) { // function body }

7.

MULTIPLE CHOICE QUESTION

45 sec • 1 pt

Construct a Java method named isPrime that takes an integer and returns a boolean indicating whether the number is a prime number.

public boolean isPrime(int number) { // method body }

public int isPrime(int number) { // method body }

public void isPrime(int number) { // method body }

public boolean isPrime(double number) { // method body }

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?