CP1344: PROGRAMMING IN JAVA - LECTURE -38-SINGLE INHERITANCE - BCA- S3.
Single inheritance
Application of single inheritance
class Room
{
int length;
int breadth;
Room(int x, int y)
{
length = x;
breadth = y;
int area( )
{
return (length * breadth);
}
}
class BedRoom extends Room
{
int height;
BedRoom(int x, int y, int z)
{
super(x, y);
height = z;
}
int volume( )
{
return (length * breadth * height);
}
}
class InherTest
{
public static void main(String args[ ])
{
BedRoom rooml = new BedRoom(14.12,103);
int areal = rooml.area( );
int volumel = rooml.volume( );
System.out.println("Areal = “+ areal);
System.out.println( “Volume = “+ volume);
}
}
The program defines a class Room and extends it to another class BedRoom. Note that the class BedRoom defines its own data members and methods. The subclass BedRoom now includes three instance variables, namely, length, breadth and height and two methods, area and volume.
The constructor in the derived class uses the super keyword to pass values that are required by the base constructor, The statement
BedRoom rooml = new BedRoom(4,12,10);
calls first the BedRoom constructor method, which in tum calls the Room constructor method by using the super keyword.
Finally, the object room of the subclass BedRoom calls the method area defined in the super class as well as the method volume defined in the subclass itself.
Subclass Constructor
A subclass constructor is used to construct the instance variables of both the subclass and the superclass. The subclass constructor uses the keyword super to invoke the constructor method of the superclass. The keyword super is used subject to the following conditions.
super may only be used within a subclass constructor method
The call to superclass constructor must appear as the first statement within the subclass constructor
The parameters in the super call must match the order and type of the instance variable declared in the superclass.
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «CP1344: PROGRAMMING IN JAVA - LECTURE -38-SINGLE INHERITANCE - BCA- S3.», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.