share this page !

search

Monday, June 7, 2010

JAVA : Inheritance. A class Network given. The class Admin derives info from class Account which in turn derives from class Person.display Admin object.


only for presentation purposes 
Here are the Mumbai University First Year Engineering sem-2 Computer programing 2 (CP-2) programs.These are tried and tested and work just fine.Njoy!
Please refer this to all your pals on all your social networks..thank you !
The grey color is only for the background it should cause no problems.
-----------------------------------------------------------------------------------------------------------
class Person
{
    String name;
    int code;
    Person()
{
}
Person(String n,int c)
{
    name=n;
    code=c;
}
void display()
{
    System.out.println("name is"+name+"code is"+code);
}
}
class Account extends Person
{
    long pay;
    Account()
{
}
    Account(String n,int c,long p)

{
    super(n,c);
    pay=p;
}
void display()
{
    super.display();
    System.out.println("pay is"+pay+"rs");
}
}
class Admin extends Account
{
    int exp;
    Admin()
{
}
    Admin(String n,int c,long p,int e)
{
    super(n,c,p);
    exp=e;
    System.out.println("EXP is"+exp+"years");
}
}

class Network
{
public static void main(String args[])
{
    Admin a=new Admin("yourname",102,2000000,2);
    a.display();
}
}

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...

Followers

 

Mumbai University Engineering. Copyright 2008 All Rights Reserved Revolution Two Church theme by Brian Gardner Converted into Blogger Template by Bloganol dot com