Sunday, February 25, 2018

Java program : Storing objects in Array

class Animal
{ {System.out.println("Animal");}
}
class Dog extends Animal
{ {System.out.println("Dog");}
}
class DogKid extends Dog
{ {System.out.println("DogKid");}
}
class ArrayInFamily
{       
       
        static void m1()
        {
           Animal[] a=new Animal[3];
          { a[0] = new Animal();
            a[2] = new DogKid();
            for(Animal aa:a )
                {
                    System.out.println(aa);
                }
          }
        } 
        public static void main(String[] args)
        {
                m1();
               
        }   
}   

Thanks
Happy programming!

No comments:

Post a Comment

Henry's law constant for CO 2 ​ in water is 1.67×10 ∘ Pa at 298 K . Calculate the quantity of CO 2 ​ in 500 mL , of soda water when packed under 2.5 atm CO 2 ​ pressure at 298 K .

  Explanation To calculate the amount of CO 2 ​ dissolved, we use Henry's Law: P = k H ​ × x _ C O 2 ​ where:\ P = partial pressure of...