Lesson 16 Answers Part 1

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Answers 16-3

.H\WR([HUFLVHIRU/HVVRQ

Problems 1 5 refer to the following code (assume that HTXDOV is not an explicit, method
of this class):

MoonRock myRock = new MoonRock(3, Xeon);


MoonRock yourRock = new MoonRock(2, Kryptonite);
MoonRock ourRock = new MoonRock(3, Xeon);
MoonRock theRock;
theRock = ourRock;
1. Does WKH5RFNHTXDOV RXU5RFN return a true or false?

WUXH

2. Does WKH5RFNHTXDOV \RXU5RFN return a true or false?

IDOVH

3. Does WKH5RFNHTXDOV P\5RFN return a true or false?

IDOVH

4. Does P\5RFN  RXU5RFN return a true or false?

IDOVH

5. Does P\5RFNHTXDOV \RXU5RFN return a true or false?

IDOVH

Problems 6 11 refer to the following code:


public class Weenie
{
public Weenie( )
{


public String method1(int jj)


{

}
private void method2(String b)
{

}
public int method3( )
{

}
public double x;
public int y;
private String z;
}
Now suppose from within a different class we instantiate a :HHQLH object,
RVFDU0D\HU. All of the code in questions 6 11 is assumed to be in this other
class.
6. Is

LQW]] RVFDU0D\HUPHWKRG   legal? If not, why?


1RPHWKRGUHWXUQVD6WULQJDQGZHDUHWU\LQJWRVWRUHLWLQ[[DQLQW

You might also like