AP Computer Science A Void

AP Computer Science A Void

8th - 12th Grade

5 Qs

quiz-placeholder

Similar activities

Arrays

Arrays

10th - 12th Grade

10 Qs

Advanced Java Study Guide

Advanced Java Study Guide

11th - 12th Grade

10 Qs

#119 Topic 2.3 Video 2

#119 Topic 2.3 Video 2

11th Grade

5 Qs

AP CSA Unit 1 & 2 Review

AP CSA Unit 1 & 2 Review

9th - 12th Grade

10 Qs

C# lesson10

C# lesson10

1st - 10th Grade

10 Qs

C# 12

C# 12

10th Grade

10 Qs

Java String class methods

Java String class methods

10th - 12th Grade

10 Qs

Search for Content on Methods in Java

Search for Content on Methods in Java

11th - 12th Grade

10 Qs

AP Computer Science A Void

AP Computer Science A Void

Assessment

Quiz

Computers

8th - 12th Grade

Medium

Created by

ALPA DANI

Used 28+ times

FREE Resource

5 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is an instance method?

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.