This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes method overriding and overloading Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "method overriding and overloading" Watch "method overriding and overloading" New topic
Author

method overriding and overloading

Chris Cairns
Ranch Hand

Joined: Jan 31, 2003
Posts: 48
the answer to this question:
If a base class has a method defined as
void method() { }
Which of the following are legal prototypes in a derived class of this class. Select the two correct answers.
a. void method() { }
b. int method() { return 0;}
c. void method(int i) { }
d. private void method() { }
Answer: A, C
[Dan changed to subject title to something more descriptive. Please use descriptive subject titles.]
[ March 03, 2003: Message edited by: Dan Chisholm ]
John Paverd
Ranch Hand

Joined: Nov 17, 2002
Posts: 115
If a base class has a method defined as
void method() { }
Which of the following are legal prototypes in a derived class of this class. Select the two correct answers.
A. void method() { }
OK. This is a legal override.
B. int method() { return 0;}
Invalid. You can't change the return type when you override a method.
C. void method(int i) { }
OK. Since the parameter list is different, method is being overloaded, not overridden.

D. private void method() { }
Invalid. You cannot narrow access to methods when overriding them.
[ March 03, 2003: Message edited by: John Paverd ]

SCJP 1.4
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: method overriding and overloading
 
Similar Threads
Question for Dan Wrapper Class
question from Sun Guoqiao's homepage
references and method parameters
help me in kicking off the bug from the following code
Operator Precedence involving && and ||