Consider the implementation of the Date class shown below. public class Date
{
private int myDay;
private int myMonth:
private int myYear;

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

public Date(int mo, int day, int yr)
{ /* implementation not shown */ }

public int getMonth( ) //returns month of date
{ /* implementation not shown */ }

public int getDay( ) //returns day of date
{ /* implementation not shown */ }

public int getYear( ) //returns year of date
{ /* implementation not shown */ }

//string representation of Date as "m/d/y", e.g. 4/18/1985
public String toString( )
{ /* implementation not shown */ }
}
A separate client/tester class instantiates a Date object named d with the following Java statement:

Date d = new Date (1, 13, 2002);
Which of the following subsequent code segments will cause a compile-time error?

String s = d.toString();
Date e = new Date(1, 13, 2002);
int y = d.myYear;
int x = d.getDay();

Solved
Show answers

Ask an AI advisor a question