Question
Assume that date1 and date2 are objects of class IncDate as defined in Section 1.2 Organizing Classes. What would be the output of the following
Assume that date1 and date2 are objects of class IncDate as defined in Section 1.2 Organizing Classes. What would be the output of the following code? date1 = new IncDate(5, 5, 2000); date2 = new IncDate(5, 5, 2000); System.out.println(date1); System.out.println(date2); date1.increment(); System.out.println(date1); System.out.println(date2); date1 = date2; System.out.println(date1); System.out.println(date2);
Make sure that the dates are in the format of "1/30/2010" (Do not pad leading 0 for days or months). Refer to the toString method defined on Page 3 of the textbook for more details.
Given the definition of the Person and Student classes below,
public class Person { public String m_name; protected int m_age;
public Person(String name, int age) { m_name = name; m_age = age; }
public int getAge() { return m_age; } }
public class Student extends Person { private double m_gpa;
public Student(String name, int age, double gpa) { super(name, age); m_gpa = gpa; } public void decrementAge() { m_age--; } }
and the following statements:
Person p = new Person("Joe Doe", 25); Student s = new Student("Jane Doe", 20, 3.45); String name; int age; double gpa;
indicate which of the following statements are illegal, and which are legal.
Question 1 options:
|
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started