Java Reference
In-Depth Information
/**
Returns true if yearInt is a leap year.
*/
private boolean leapYear( int yearInt)
{
return ((yearInt % 4 == 0) && (yearInt % 100 != 0))
|| (yearInt % 400 == 0);
}
20. doSomething ( int , char , int )
setMonth( int )
setMonth(String)
amount( int , double )
amount( int , double )
21. Yes, it is legal because they have different signatures. This is a valid example of
overloading.
22. No, it would be illegal because they have the same signature.
23. No, it would be illegal. You cannot overload on the basis of the type of the
returned value.
24. If a class is named CoolClass , then all constructors must be named CoolClass .
25. YourClass anObject = new YourClass(42, 'A');//Legal
YourClass anotherObject = new YourClass(41.99, 'A');//Not legal
YourClass yetAnotherObject = new YourClass();//Legal
yetAnotherObject.doStuff();//Legal
YourClass oneMoreObject;//Legal
oneMoreObject.doStuff();//Not legal
oneMoreObject.YourClass(99, 'B');//Not legal
26. A no-argument constructor is a constructor with no parameters. If you define a
class and define some constructors but do not define a no-argument constructor,
then the class will have no no-argument constructor. Default constructor is
another name for a no-argument constructor.
27. The last line would be the same. Because the blank space is a delimiter, a blank
space is enough to separate the tokens.
28. Hello Dick and Tom
The other token in the input line is just not used.
Search WWH ::




Custom Search