AP Computer Science Unit 2 – Test Review Practice Questions

Access More Questions
Questions 5–11 refer to the following Date class declaration: public class Date { private int day; private int month; private int year; public Date() //default constructor { ... } public Date(int mo, int da, int yr) //constructor { ... } public int month() //returns month of Date { ... } public int day() //returns day of Date { ... } public int year() //returns year of Date { ... } //Returns String representation of Date as "m/d/y", e.g. 4/18/1985. public String toString() { ... } } Which of the following correctly constructs a Date object in a client class?
Correct Answer:
Date d = new Date(2, 13, 1947);
Explanation:
Correct answer: Date d = new Date(2, 13, 1947);

Access more questions from this quiz

Continue to AP Computer Science Unit 2 – Test Review Practice Questions for more practice questions and the full quiz experience.

Access More Questions