Methods

Quiz
•
Computers
•
University
•
Medium
Montserrat Molina
Used 6+ times
FREE Resource
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
10 sec • 1 pt
What do I put as the return type if I don't want to return anything from a method?
int
none
void
leave it empty!
2.
MULTIPLE CHOICE QUESTION
10 sec • 1 pt
True or False:
A method does not need to have any parameters.
True
False
3.
MULTIPLE CHOICE QUESTION
20 sec • 1 pt
What is the correct way to define a method that subtracts two numbers, returning the difference?
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)
4.
FILL IN THE BLANK QUESTION
20 sec • 1 pt
Fill in the blank for defining a method that returns the square root of a number:
public static ___ squareRoot(double number);
5.
MULTIPLE CHOICE QUESTION
20 sec • 1 pt
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.
6.
MULTIPLE SELECT QUESTION
30 sec • 1 pt
Select all of the following code snippets that are correct for calling a method sum, which returns the sum of two numbers:
int sum = add(5, 7);
System.out.println(add(5,7));
add(5);
add(5,7);
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Why is the following call to method minOfTwo, which returns the minimum number of 2 given numbers, incorrect?
int min = minOfTwo(8,"9");
The method minOfTwo only takes in one parameter.
The method minOfTwo does not return anything.
The method minOfTwo takes in two integers, but a String is being passed in.
There is nothing incorrect with this method call.
Create a free account and access millions of resources
Similar Resources on Wayground
10 questions
Basics Of C Programming

Quiz
•
University
10 questions
C - Pointers

Quiz
•
University
15 questions
CODE ZENITH

Quiz
•
University
15 questions
Coding club Summit Online Quiz

Quiz
•
University
10 questions
NumpyPandas

Quiz
•
University
10 questions
Weekly Contest #3 - TechXNinjas

Quiz
•
University
15 questions
java básico y pilas

Quiz
•
University
7 questions
C++ klases (1)

Quiz
•
University
Popular Resources on Wayground
10 questions
Video Games

Quiz
•
6th - 12th Grade
20 questions
Brand Labels

Quiz
•
5th - 12th Grade
15 questions
Core 4 of Customer Service - Student Edition

Quiz
•
6th - 8th Grade
15 questions
What is Bullying?- Bullying Lesson Series 6-12

Lesson
•
11th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
22 questions
Adding Integers

Quiz
•
6th Grade
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
Discover more resources for Computers
20 questions
Definite and Indefinite Articles in Spanish (Avancemos)

Quiz
•
8th Grade - University
7 questions
Force and Motion

Interactive video
•
4th Grade - University
36 questions
Unit 5 Key Terms

Quiz
•
11th Grade - University
7 questions
Figurative Language: Idioms, Similes, and Metaphors

Interactive video
•
4th Grade - University
15 questions
Properties of Equality

Quiz
•
8th Grade - University
38 questions
WH - Unit 3 Exam Review*

Quiz
•
10th Grade - University
21 questions
Advise vs. Advice

Quiz
•
6th Grade - University
12 questions
Reading a ruler!

Quiz
•
9th Grade - University