Programming and Problem Solving with Java

(やまだぃちぅ) #1
371

6.Is the following code segment correct? If so, to what does each reference tovarre-
fer?
public classSomeClass
{
intvar; // Class member var
final intCONST = 3 ; // Class member CONST
public voidsomeMethod(intparam)
{
intvar;
var = param * CONST;
final intCONST = 10 ;
var = 5 ;
System.out.println(""+ this.var);
}
}


7.Examine the following constructor headings and give the signature for each.


publicsomeClass()
publicsomeClass(inta)
publicsomeClass(doublea)
publicsomeClass(String a, intb, doublec)

8.Examine the following method headings and give the signature for each. Could
methods with these signatures all be declared within one class?
public intsomeMethod()
public voidsomeMethod()
public doublesomeMethod()
public doublesomeMethod(inta)
public doublesomeMethod(String a)
public doublesomeMethod(inta, intb)


9.Are these code segments correct? If not, why not?


a.public doubletaxRate = 29.3;
public doublemyRate = taxRate*1.1;
b.public doublemyRate = taxRate*1.1;
public doubletaxRate = 29.3;
Free download pdf