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:

12

p.decrementAge();

12

age = s.getAge();

12

age = p.getAge();

12

s.decrementAge();

12

gpa = s.m_gpa;

12

name = p.m_name;

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!