Choosing how to earn college credit? CLEP vs AP guide
| preferred AP College board partner for AP classes
AP Computer Science A/Unit 3: Class Creation
Start Practice TestPractice Test
About Exam
medium Solved by 7 students

Client Class Method Implementation

Mark
< Prev
Next >

Consider the following Time class definition.

public class Time
{
    private int hrs;
    private int mins;
    private int secs;

    public Time()
    { /* implementation not shown */ }

    public Time(int h, int m, int s)
    { /* implementation not shown */ }

    /** Resets time to hrs = h, mins = m, secs = s. */
    public void resetTime(int h, int m, int s)
    { /* implementation not shown */ }

    /** Advances time by one second. */
    public void increment()
    { /* implementation not shown */ }

    /** Returns true if this time equals t, false otherwise. */
    public boolean equals(Time t)
    { /* implementation not shown */ }

    /** Returns true if this time is earlier than t, false otherwise. */
    public boolean lessThan(Time t)
    { /* implementation not shown */ }

    /** Returns a String with the time in the form hrs:mins:secs. */
    public String toString()
    { /* implementation not shown */ }
}

The following display method is part of a client class and is intended to print the time represented by its parameter t.

/** Outputs time t in the form hrs:mins:secs. */
public void display(Time t)
{
    /* method body */
}

Which of the following code segments, if used to replace /* method body */, will correctly implement the display method?

I.

Time T = new Time(h, m, s);
System.out.println(T);

II.

System.out.println(t.hrs + ":" + t.mins + ":" + t.secs);

III.

System.out.println(t);
A

II only

B

I only

C

II and III only

D

III only

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer
Report Question

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Total Time
Score
#1dinhhoa12 - 90
#2sailajavadlamani3314 - 70
#3Ishaan.m.kurup15 - 60
#4busemagngr01 1m 06s -76
#5y.seong202701 2m 25s -155
#6songqiuhui201201 3m 07s -197
#7psak1202 3m 33s -233
#8varunrajaram101 3m 47s -237
#9bommasam00026 9m 17s -397
#10suhanakochhar00614 10m 15s -545
Items per page:
10
1 – 10 of 10
No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Instagram: @_apfive_|Privacy Policy|