Sunday 30 September 2012

Java Practical - 20




Program Definition 20 ::


Define one class E in package epack.  In class E, three variables are defined of access modifiers protected, private & public. Define class F in package fpack which extends E and write display() method which access variables of class E.  Define class G in package gpack which has one method display() in that create one object of class E and display its variables.  Define class ProtectedDemo in package hpack in which write main() method.  Create objects of class F and G and class display method for both these objects.
 



interface I1
{
}

interface I2
{
}

interface I3 extends I1,I2
{
}

interface I4
{
}

class X implements I3
{
}

class W extends X implements I4
{
}

class Prog20
{
public static void main( String args[] )
{
W wObj = new W();

if ( wObj instanceof I1 )
System.out.println(" W implements I1 ");
if ( wObj instanceof I2 )
System.out.println(" W implements I2 ");
if ( wObj instanceof I3 )
System.out.println(" W implements I3 ");
if ( wObj instanceof I4 )
System.out.println(" W implements I4 ");
if ( wObj instanceof X )
System.out.println(" W extends X ");
}
}

/*

D:\JAVA >javac Prog20.java

D:\JAVA >java Prog20
 W implements I1
 W implements I2
 W implements I3
 W implements I4
 W extends X
*/


Kindly Bookmark and Share it:

0 comments :

Post a Comment

Any Query ? any suggestion ? comment here

 

Recent Post

Recent Comments

© 2010 IamLearningHere Template by MBT