Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning ASP.NET 2.0 And Databases

Authors: John Kauffman, Bradley Millington

1st Edition

0471781347, 978-0471781349

More Books

Students also viewed these Databases questions

Question

What is the difference between a share dividend and a share split?

Answered: 1 week ago

Question

Subtract in the base indicated. A7B12 9512

Answered: 1 week ago

Question

Why does sin 2x + cos2x =1 ?

Answered: 1 week ago

Question

What are DNA and RNA and what is the difference between them?

Answered: 1 week ago

Question

Why do living creatures die? Can it be proved that they are reborn?

Answered: 1 week ago