File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Mock Exam Errata and the fly likes JavaRanch #19 Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Mock Exam Errata
Reply Bookmark "JavaRanch #19" Watch "JavaRanch #19" New topic
Author

JavaRanch #19

Guy Scharf
Greenhorn

Joined: Mar 17, 2000
Posts: 1
This question asks: "TRUE or FALSE: methods which are marked protected can be called on any subclass of the class in which the method is declared." The answer is given as TRUE.
What does "called on any subclass" mean? That answer is certainly true if "on" means "in".
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18670
When I read "called on any subclass" I imagine we're talking about taking an instance of the subclass and using it to invoke the method, as in subclassInstance.protectedMethod(). This would make the statement FALSE since you can't do that from within an unrelated class. I think you're right that the question was meant to say "in" rather than "on".


"I'm not back." - Bill Harding, Twister
paul wheaton
Trailboss

Joined: Dec 14, 1998
Posts: 19672
    ∞

The change is made.
(I'm sure glad I numbered the questions!)


permaculture forums
Pete Pan
Ranch Hand

Joined: Mar 14, 2001
Posts: 44
I still think is it FALSE (so
class A
{
protected void printName()
{
System.out.println("A");
}
}
class B extends A
{
protected void printName()
{
System.out.println("B");
}
}
class C extends B
{
protected void printName()
{
System.out.println("C");
}

static void main(String argc[])
{
//HOW DO I CALL A's printName, I don't
}
}
Amit Madan
Ranch Hand

Joined: Dec 20, 2000
Posts: 32
Hi
you can call A's method by making object of A like
A ob1=new A();
ob1.printName();
which give output "A"

Amit
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: JavaRanch #19
 
Similar Threads
beta round up question 19
constructor
Exception Question
When is validate called on a DynaValidatorForm?