Beispiel #1
0
            static void Main()
            {
                SBI sbi = new SBI();

                sbi.Educationloan();
                sbi.Homeloan();
                Console.WriteLine("sbi house loan: {0}", sbi.Homeloan());
                Console.WriteLine("sbi education loan: {0}", sbi.Educationloan());

                HDFC hdfc = new HDFC();

                Console.WriteLine("hdfc houseloan {0}", hdfc.Homeloan());
                Console.WriteLine("hdfc educationloan {0}", hdfc.Educationloan());


                ///run time polymorphism
                RBI r;

                //object for SBI
                r = new SBI();
                r.RBIemployee();
                Console.WriteLine("sbi houseloan {0}", r.Homeloan());
                Console.WriteLine("sbi educationloan {0}", r.Educationloan());
                //object for HDFC
                Console.WriteLine("hdfc houseloan {0}", r.Homeloan());
                Console.WriteLine("hdfc educationloan {0}", r.Educationloan());

                Console.Read();
            }
Beispiel #2
0
        static void Main()
        {
            //cant create object for abstract class
            //RBI r = new RBI ();

            /*  SBI sbi = new SBI();
             * sbi.RBIEmployee();
             * Console.WriteLine("sbi h loan:{0}", sbi.Homeloan());
             * Console.WriteLine("sbi E loan:{0}", sbi.Educationloan());
             * HDFC hdfc = new HDFC();
             * Console.WriteLine("hdfc h loan:{0}", hdfc.Homeloan());
             * Console.WriteLine("hdfc E loan:{0}", hdfc.Educationloan());
             */
            //Run Time Polymorphism
            RBI r;

            // Object for SBI
            r = new SBI();
            r.RBIEmployee();
            Console.WriteLine("sbi h loan:{0}", r.Homeloan());
            Console.WriteLine("sbi E loan:{0}", r.Educationloan());
            r = new HDFC();
            Console.WriteLine("hdfc h loan:{0}", r.Homeloan());
            Console.WriteLine("hdfc E loan:{0}", r.Educationloan());
            Console.Read();
        }
        static void Main()
        {
            //can not create boject for abstract class
            //RBI r =new RBI();

            SBI sbi = new SBI();

            sbi.RBIEmployee();
            Console.WriteLine("SBI h loan:{0}", sbi.Homeloan());
            Console.WriteLine("SBI E loan:{0}", sbi.Educationloan());

            HDFC hdfc = new HDFC();

            Console.WriteLine("HDFC h loan:{0}", hdfc.Homeloan());
            Console.WriteLine("HDFC E loan:{0}", hdfc.Educationloan());

            //Run time polymorphism
            Console.WriteLine("----------------------------");
            Console.WriteLine("Run time polymorphism");

            //reference of RBI
            RBI r;

            //object for SBI
            r = new SBI();
            r.RBIEmployee();
            Console.WriteLine("SBI h loan:{0}", r.Homeloan());
            Console.WriteLine("SBI E loan:{0}", r.Educationloan());

            r = new HDFC();
            Console.WriteLine("HDFC h loan:{0}", r.Homeloan());
            Console.WriteLine("HDFC E loan:{0}", r.Educationloan());

            Console.Read();
        }
        static void Main()
        {
            // cannot create object for abstract class ie RBI class
            // to access non abstarct methods in abstract class. either of child class object
            // can be used.

            /*SBI sbi = new SBI();
             * sbi.RBIEmployee();
             *
             * Console.WriteLine(" SBI HOMELOAN:{0}", sbi.Homeloan());
             * Console.WriteLine(" SBI EDUCATIONALLOAN:{0}", sbi.Educationalloan());
             *
             * HDFC hdfc = new HDFC();
             * Console.WriteLine(" HDFC HOMELOAN:{0}", hdfc.Educationalloan());
             * Console.WriteLine(" HDFC EDUCATIONALLOAN:{0}", hdfc.Educationalloan());
             * Console.Read();*/

            // Runtime polymorphism
            RBI r; // reference creation for RBI

            // creation of object for SBI
            r = new SBI();
            r.RBIEmployee();
            Console.WriteLine(" SBI HOMELOAN:{0}", r.Homeloan());
            Console.WriteLine(" SBI EDUCATIONALLOAN:{0}", r.Educationalloan());

            r = new HDFC();
            Console.WriteLine(" HDFC HOMELOAN:{0}", r.Homeloan());
            Console.WriteLine(" HDFC EDUCATIONALLOAN:{0}", r.Educationalloan());
            Console.WriteLine("Changes made ");

            Console.Read();

            // in runtime polymorphism reference created for RBI (r),
            //refers object created for SBI first and same reference refers object created for
            // HDFC so, unwanted memory creation unlike two object creation can be eliminated.
        }
Beispiel #5
0
        static void Main()
        {
            SBI  sbi  = new SBI();
            HDFC hdfc = new HDFC();

            //cant create object for abstract class (rbi)
            //RBI r = new RBI
            //so,accessing rbi informt through sbi and hdfc
            sbi.RBIEmployee();
            hdfc.RBIEmployee();
            Console.WriteLine("SBI --- education loan  = {0} || Homeloan = {1}", sbi.Educationloan(), sbi.Homeloan());
            Console.WriteLine("HDFC----education loan = {0} || Homeloan = {1}", hdfc.Educationloan(), hdfc.Homeloan());

            //Run Time Polymorphism ex: over riding
            RBI r;

            //object creation for SBI,refering to RBI r
            r = new SBI();
            Console.WriteLine("run time polymorphism");
            r.RBIEmployee();
            Console.WriteLine("SBI education loan  = {0}and SBI Homeloan = {1}", r.Educationloan(), r.Homeloan());
            r = new HDFC();
            Console.WriteLine("HDFC education loan  = {0} and HDFC Homeloan = {1}", r.Educationloan(), r.Homeloan());

            Console.Read();
        }