What do I put as the return type if I don't want to return anything from a method?
Methods

Flashcard
•
Computers
•
University
•
Hard
Quizizz Content
FREE Resource
Student preview

8 questions
Show all answers
1.
FLASHCARD QUESTION
Front
Back
void
2.
FLASHCARD QUESTION
Front
True or False: A method does not need to have any parameters.
Back
True
3.
FLASHCARD QUESTION
Front
What is the correct way to define a method that subtracts two numbers, returning the difference? Options: public static void subtract(int num1, int num2), public static int subtract (int num1, int num2), public static int subtract(String num1, String num2), public static void subtract(int num1, num2)
Back
public static int subtract (int num1, int num2)
4.
FLASHCARD QUESTION
Front
Which of the following statements is false?
A method is good for reusing code.
A method with a return type must return a variable of that return type.
A method must always have at least 1 parameter.
A method with a void return type must not return anything.
Back
A method must always have at least 1 parameter.
5.
FLASHCARD QUESTION
Front
Why is the following call to method minOfTwo, which returns the minimum number of 2 given numbers, incorrect? int min = minOfTwo(8,"9");
Back
The method minOfTwo takes in two integers, but a String is being passed in.
6.
FLASHCARD QUESTION
Front
True or False: There is something incorrect about the following call to the method minOfTwo: int min = minOfTwo(int 8, int 9);
Back
True
7.
FLASHCARD QUESTION
Front
What is wrong with the following code snippet?
public static multiply(int a, int b) {
return a * b;
}
Back
It is missing the int return type in the method definition.
8.
FLASHCARD QUESTION
Front
What will be printed from the following code snippet, where minOfTwo is a method that returns the minimum number?
System.out.println(minOfTwo(10,-1));
Back
-1
Similar Resources on Quizizz
11 questions
Java String Objects & Methods

Flashcard
•
12th Grade
10 questions
CAPITAL BUDGETING

Flashcard
•
University
4 questions
flashcard - Papo formativo_Pensamento computacional_EM_R7

Flashcard
•
KG - University
7 questions
BTS

Flashcard
•
University
4 questions
MethodHeadingChecker

Flashcard
•
12th Grade
6 questions
Code.org CSP Unit 4 Review

Flashcard
•
9th - 12th Grade
11 questions
Computer Programming

Flashcard
•
University
10 questions
Java Classes and Objects

Flashcard
•
12th Grade
Popular Resources on Quizizz
15 questions
Character Analysis

Quiz
•
4th Grade
17 questions
Chapter 12 - Doing the Right Thing

Quiz
•
9th - 12th Grade
10 questions
American Flag

Quiz
•
1st - 2nd Grade
20 questions
Reading Comprehension

Quiz
•
5th Grade
30 questions
Linear Inequalities

Quiz
•
9th - 12th Grade
20 questions
Types of Credit

Quiz
•
9th - 12th Grade
18 questions
Full S.T.E.A.M. Ahead Summer Academy Pre-Test 24-25

Quiz
•
5th Grade
14 questions
Misplaced and Dangling Modifiers

Quiz
•
6th - 8th Grade