Back to Browse

ABSTRACT CLASS IN JAVA in Hindi Lecture 77

11 views
May 30, 2026
9:19

//Abstraction in Java Abstraction is the process of hiding implementation details(hiding internal details) and showing only essential features.Abstraction allows you to focus on what an object does rather than how it does it. Example----A driver only knows to drive the car and he does not know how the car engine has been manufactured. There are three ways to achieve abstraction in Java------ 1.Using Abstract Class 2.Using Abstract Method 3.Using Interface //Abstract Class 1.A class which contains the abstract keyword in its declaration is known as abstract class. 2.We cannot create object of abstract class.We create the object of child class. 3.The abstract class can be extended by child class. 4.Abstract class may or may not contain abstract methods i.e methods can be declare only but we donot give implementation or give definition of method. Syntax- abstract return-type method_name(); Example ----- abstract void show(); 5.If a class has at least one abstract method then class must be declared abstract. 6.We give implementation of abstract method in child class. //Abstract class in Java //Abstract class may or may not contain abstract method //Abstract class object cannot be created.Its child class object can be created. //w.a.p to create abstract class and calculate sum and multiply. abstract class calculate { int a,b; public void enter(int a,int b) { this.a=a; this.b=b; } public void display() { System.out.println("a="+a); System.out.println("b="+b); } } class sum extends calculate { int s; public void cal1() { s=a+b; System.out.println("sum="+s); } } class multiply extends calculate { int m; public void cal2() { m=a*b; System.out.println("multiply="+m); } } class example { public static void main(String args[]) { sum obj1=new sum(); obj1.enter(10,20); obj1.display(); obj1.cal1(); multiply obj2=new multiply(); obj2.enter(90,80); obj2.display(); obj2.cal2(); } }

Download

1 formats

Video Formats

360pmp47.6 MB

Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.

ABSTRACT CLASS IN JAVA in Hindi Lecture 77 | NatokHD