Java Reference
In-Depth Information
public void
setData(
int
a,
int
b,
int
c)
{
//Postcondition: x = a; y = b; z = c;
}
public void
print()
{
//Output the values of x, y, and z
}
}
a.
Write the definition of the method
setData
of the
class
Two
as
described in the class definition.
b.
Write the definition of
the method
print
of
the
class
Two
as
described in the class definition.
18.
Explain the difference between the
private
and
protected
members of a
class.
19.
Explain the difference between the
public
and
protected
members of a
class.
Suppose that you have the following class definitions:
public class
SuperClass
{
20.
protected int
x;
private
String str;
public void
print()
{
System.out.println(x + " " + str);
1
0
}
public
SuperClass()
{
str = "";
x = 0;
}
public
SuperClass(String s,
int
a)
{
str = s;
x = a;
}
}
public class
SubClass
extends
SuperClass
{
private int
y;
public void
print()
Search WWH ::
Custom Search