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 Java in General and the fly likes Troubling with this code 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 » Java » Java in General
Bookmark "Troubling with this code" Watch "Troubling with this code" New topic

Troubling with this code

Vimal Kumar Venugopal
Ranch Hand

Joined: Aug 20, 2011
Posts: 43

package packA;

public class Beverage {
public static void main(String[] args) {
package packB;

import packA.Beverage;

class Tea extends Beverage {

and when i run Tea class..
I get the output as"hi"!!!

How does this happen??

"Value has a Value only if its value is valued!"
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4340

when you extend a class you inherit all its members. i guess that includes main()

Visit my download page
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 37943
. . . and welcome to the Ranch
subject: Troubling with this code
Similar Threads
K&B: :Page 14 Default Access - misleading sentence
Question on Packages from Kathy Sierra Book
packages from KB
what happens at runtime?
import vs extend?