Saturday 28 July 2012

multilevel inheritance example java program


class students
{
        private int sno;
        private String sname;
        public void setstud(int no,String name)
        {
                sno = no;
                sname = name;
        }
        public void putstud()
        {
                System.out.println("Student No : " + sno);
                System.out.println("Student Name : " + sname);
        }
}
class marks extends students
{
        protected int mark1,mark2;
        public void setmarks(int m1,int m2)
        {
                mark1 = m1;
                mark2 = m2;
        }
        public void putmarks()
        {
                System.out.println("Mark1 : " + mark1);
                System.out.println("Mark2 : " + mark2);
        }
}
class finaltot extends marks
{
        private int total;
        public void calc()
        {
                total = mark1 + mark2;
        }
        public void puttotal()
        {
                System.out.println("Total : " + total);
        }
        public static void main(String args[])
        {
                finaltot f = new finaltot();
                f.setstud(100,"Nithya");
                f.setmarks(78,89);
                f.calc();
                f.putstud();
                f.putmarks();
                f.puttotal();
        }
}

9 comments:

  1. Its easy to understand the programme and very easy to learn .thanks to sharing this article .
    java training center in chennai | java training institute in chennai


    ReplyDelete
  2. I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.
    Selenium training in Chennai

    Selenium training in Bangalore

    ReplyDelete
  3. It's very helpful to ne, thank you

    ReplyDelete
  4. After reading this web site I am very satisfied simply because this site is providing comprehensive knowledge for you to audience.
    Thank you to the perform as well as discuss anything incredibly important in my opinion. We loose time waiting for your next article writing in addition to I beg one to get back to pay a visit to our website in




    Selenium training in bangalore
    Selenium training in Chennai
    Selenium training in Bangalore
    Selenium training in Pune
    Selenium Online training

    ReplyDelete
  5. I Regreat For Sharing The information The InFormation shared Is Very Valuable Please Keep Updating Us Time Just Went On Reading The Article Python Online Training AWS Online Training Hadoop Online Training Data Science Online Training

    ReplyDelete
  6. Hello,
    Could you tell me that how to take those name,marks as inputs in runtime using scanner?

    ReplyDelete