File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes What will be the output of the following piece of code? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "What will be the output of the following piece of code?" Watch "What will be the output of the following piece of code?" New topic
Author

What will be the output of the following piece of code?

Sivapraveen Chandana
Greenhorn

Joined: Jan 01, 2008
Posts: 16
class Clidder {
private final void flipper(){ System.out.println("Clidder"); }
}

public class Clidlet extends Clidder {
public final void flipper(){System.out.println("Clidlet"); }
public static void main(String [] args) {
Clidder c = new Clidlet();
c.flipper();
}
}




thanks in advance..
[ January 08, 2008: Message edited by: Sivapraveen Chandana ]

praveen
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24166
    
  30

Why ask people to tell you, when you could simply compile and run it?

This is obviously an SCJP question, so I'll move this to the appropriate forum.


[Jess in Action][AskingGoodQuestions]
Arjun Cheng
Greenhorn

Joined: Jan 08, 2008
Posts: 13
It's not going to run.
Dean Jones
Ranch Hand

Joined: Dec 29, 2007
Posts: 129
This code won't go past the compiler, as in the subclass you are trying to call a private method of the superclass, which is not visible.
[ January 08, 2008: Message edited by: Dean Jones ]
Raghu Doppalapudi
Greenhorn

Joined: Jun 26, 2007
Posts: 6

If the code is as above works fine and prints clidlet.
In the code you posted you are trying to access private method which is not visible.


Doppalapudi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What will be the output of the following piece of code?
 
Similar Threads
new class.method()
Access modifiers
Reference variable casting
final methods
StringBuffer