RUVIDEO
Поделитесь видео 🙏

Java - Day 71 (in Telugu) - difference between dynamic binding and static binding

/*
difference between static binding and dynamic binding
*/

import java.util.*;

interface Shape{
void input();
void area();
void sides();
}
class Rect implements Shape{
int len,bre;
public void input(){ Scanner sc1 = new Scanner(System.in); System.out.print("enter Rect length:"); len=sc1.nextInt(); System.out.print("enter Rect breadth:");bre=sc1.nextInt();}
public void area(){ System.out.println("Rect area:"+(len*bre)); }
public void sides(){ System.out.println("\nRect sides: 4"); }
}
class Triangle implements Shape{
int base,ht;
public void input(){ Scanner sc2 = new Scanner(System.in); System.out.print("enter triangle base:"); base=sc2.nextInt(); System.out.print("enter triangle height:");ht=sc2.nextInt();}
public void area(){ System.out.println("Triangle area:"+(base*ht/2)); }
public void sides(){ System.out.println("\nTriangle sides: 3"); }
}
class Circle implements Shape{
int rad;
public void input(){ Scanner sc4 = new Scanner(System.in); System.out.print("enter Circle radius:"); rad=sc4.nextInt(); }
public void area(){ System.out.println("Circle area:"+((22/7.0)*(rad*rad))); }
public void sides(){ System.out.println("\nCircle sides: 0"); }
}
public class DynamicBind{
public static void main(String arg[]){
Scanner sc3 = new Scanner(System.in);
System.out.println("1.Rect");
System.out.println("2.Triangle");
System.out.println("3.Circle");
System.out.print("Choose the shape (1/2/3):");
int type = sc3.nextInt();
Shape s = null;

if(type==1)
s = new Rect();
else if(type==2)
s = new Triangle();
else if(type==3)
s = new Circle();
else{
System.out.println("\ninvalid option");
System.exit(0);
}

s.input(); // dynamic binding
s.sides(); // dynamic binding: taking decision at runtime about linking/binding/relating between "method call" & "method definition"
s.area(); // dynamic binding
}
}
/*
dynamic binding is possible only when parent child relation exists.
dynamic binding is possible only when overrding involves.

solution1:
if(type==1)
s = new Rect();
else if(type==2)
s = new Triangle();
else // removed if
s = new Circle();

s.input();
s.sides();
s.area();

solution2:
if(type==1)
s = new Rect();
else if(type==2)
s = new Triangle();
else if(type==3)
s = new Circle();

if(s!=null){
s.input();
s.sides();
s.area();
}

solution3:
if(type==1)
s = new Rect();
else if(type==2)
s = new Triangle();
else if(type==3)
s = new Circle();
else
return;

s.input();
s.sides();
s.area();

solution4:
throw an exception and handle it properly.

BackEndDev
-------------
Logic Development (keyword, operator, constant, identifier, statement, token,
if-else, while/for, switch, arguments, array, function/method)
Core Java (class, object, inheritance, exception handling, multithreading, collections, other packages in Java, IO, AWT/Swing/JavaFx)

JDBC
Hibernate
JPA

Servlets/JSP
Spring
SpringBoot
MicroServices



FrontEndDev
-------------
HTML,CSS,JavaScript
AngularJs/NodeJs



FullStackDeveloper
--------------------
BackEndDev + FrontEndDev = FullStackDeveloper


Cloud
------
AWS/GCP/Azure



*/

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Java - Day 71 (in Telugu) - difference between dynamic binding and static binding», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.