> Question 1.
> The doubt is about System.out.println()
> System is a class and out is a variable in System
> class.

Yes - a public static one, which means:
a) The world can use it.
b) When the world wants to use it they prefix the name of the owning class
rather than an instance reference.

>
> a.how can you call println in System class.
println() is not in the System class, it is in the PrintStream class. You
are accessing System's public instance, which
by default is wired to 'the screen'.

>
> Question 2.
>
> AppletContext is an interface.you cannot create
> objects of interface.
> but when you call getAppletContext() method you get an
> object of the interface.How is this possible.
You are getting an implementation of the interface, an object instantiated
from a class definition that
implements this interface. You see this object from the point of view of the
interface type reference.

> In RMI also i saw a method which will give an object
> for an interface.
> how is it possible.

For the same reason as above. This is a common way of cutting down on
implementation dependencies within
systems. You define an interface (e.g. 'public interface Plok' instead of
'public class Plok'), containing a set of method signatures but no method
bodies. It is possible then to swap (even 'hot-swap' at run time)
implementations (e.g. from IBM, Sun, Netscape) without breaking the rest of
the code.

It takes a while to fully grasp the potential of this, one of the most
powerful feature of the Java language.

MD


Reply via email to