What is an instance method?
AP Computer Science A Void

Quiz
•
Computers
•
8th - 12th Grade
•
Medium
ALPA DANI
Used 28+ times
FREE Resource
5 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
An instance method is a piece of code called on a specific instance (an object) of the class.
An instance method is a piece of code that does not depend on any specific instances (objects), just on the general class.
An instance method adds functionality to a class by creating private fields.
An instance method adds functionality to the class by printing out a result.
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following is a correctly written method for the class below?
public class Timer
{
private int startMin;
private int length;
public Timer(int minute, int duration)
{
startMin = minute;
length = duration;
}
public Timer(int duration)
{
startMin = 0;
length = duration;
}
}
public void addFiveMinutes()
{
length = length + 5;
}
public addFiveMinutes()
{
length = length + 5;
}
addFiveMinutes()
{
length = length + 5;
}
public void addFiveMinutes
{
length = length + 5;
}
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following correctly calls the method addFiveMinutes on an object of the Timer class called kitchenTimer?
kitchenTimer(addFiveMinutes)
Timer.addFiveMinutes()
kitchenTimer.addFiveMinutes()
kitchenTimer.addFiveMinutes
Answered
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Suppose the class Timer has a method called startTime that prints out the starting time of the Timer.
Which of the following correctly uses this method to print out the start time of a Timer object called laundry?
System.out.println(laundry.startTime());
System.out.println(laundry.startTime);
int start = laundry.startTime();
laundry.startTime();
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
A Timer class is a class that represents a minute timer. A partial definition of the class is given below.
public class Timer
{
private int length;
public Timer(int duration)
{
length = duration;
}
public void endTime()
{
System.out.print("The timer will end in " );
System.out.print(length);
System.out.println(" minutes");
}
public void addFiveMinutes()
{
length = length + 5;
}
}
What is the output of the following main method?
public static void main(String[] args){
Timer muffins = new Timer(30);
muffins.endTime();
muffins.addFiveMinutes();
muffins.endTime();
}
The timer will end in 30 minutes
The timer will end in 30 minutes
The timer will end in 35 minutes
The timer will end in 30 minutes
The timer will end in 30 minutes
This method won’t print anything because it doesn’t have any print statements.
Similar Resources on Quizizz
10 questions
Recursion in Java (AP Computer Science A)

Quiz
•
9th - 12th Grade
8 questions
Topics 7 & 8 - Static Methods/Variables and Null Keyword

Quiz
•
12th Grade
10 questions
Programming in Java

Quiz
•
8th Grade
10 questions
AP CSA Unit 1 & 2 Review

Quiz
•
9th - 12th Grade
10 questions
C# lesson10

Quiz
•
1st - 10th Grade
10 questions
Objects & Classes

Quiz
•
11th - 12th Grade
6 questions
Topic 6.1 Video 2

Quiz
•
11th Grade
10 questions
Simulasi 4

Quiz
•
10th 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
Discover more resources for Computers
17 questions
Chapter 12 - Doing the Right Thing

Quiz
•
9th - 12th Grade
30 questions
Linear Inequalities

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

Quiz
•
9th - 12th Grade
14 questions
Misplaced and Dangling Modifiers

Quiz
•
6th - 8th Grade
20 questions
Taxes

Quiz
•
9th - 12th Grade
17 questions
Parts of Speech

Quiz
•
7th - 12th Grade
20 questions
Chapter 3 - Making a Good Impression

Quiz
•
9th - 12th Grade
20 questions
Inequalities Graphing

Quiz
•
9th - 12th Grade