Sunteți pe pagina 1din 1

Answers 15-6

17. Again, assume we have an object called EDUW instantiated from the %LEOH6WRU\ class.
What should you fill in for <#1> below in order that VVV be stored in the variable MM?
<#1> jj = bart.sss;
6WULQJ
18. Create a class called 7UDLO. It should have instance fields [ and \ that are integers.
Instance field V should be a 6WULQJ. The constructor should receive a 6WULQJ which is
used to initialize V. The constructor should automatically set [ and \ both equal to 10.
There should be a method called PHW that returns a 6WULQJ that is the hex equivalent of
[ \. This method receives no parameters.
SXEOLFFODVV7UDLO
^
 SXEOLF7UDLO 6WULQJWHPS 
^
 
V WHPS
[ 
 
 
\ 
`

 SXEOLF6WULQJPHW  
^

UHWXUQ,QWHJHUWR+H[6WULQJ [ \ 
`

 SXEOLFLQW[\
 SXEOLF6WULQJV
`
19. Suppose you wish to call a method whose signature is:
public double peachyDandy(int z)
Write code that would call this method (assume we have an object name ]LSSR). Also
assume that this code will be placed in the PDLQ method of a 7HVWHU class and that the
SHDFK\'DQG\ method is in some other class.
GRXEOHF ]LSSRSHDFK\'DQG\  
20. Refer to the info in 19 above. Whats wrong with trying to call this method in the
following fashion?
double hamburger = zippo.peachyDandy(127.31);
:HFDQWSDVVDVDSDUDPHWHUVLQFHWKHPHWKRGLVH[SHFWLQJDQ
LQWHJHUSDUDPHWHU.

S-ar putea să vă placă și