Abstraction in Java || Abstract Classes and Methods Frequently asked Interview Question| Code Decode

preview_player
Показать описание
Learn how to make abstract classes and methods and the difference between abstract classes and interfaces!

Udemy Course of Code Decode on Microservice k8s AWS CICD link:

Course Description Video :

Abstract classes in java can be tricky at first... But SURELY you'll get it :) If you followed along :-)

#abstraction #abstractClassesAndMethod #abstractionInJava

Рекомендации по теме
Комментарии
Автор

Such an dedicated and helpful lady....She is suffering from ill, but still taking the classes n helping everyone out there. Hats Off to the dedeication Mam💯❤️

arpitsik
Автор

Blessed be this woman, she is ill and still tried her best to make the content as interesting as possible! hatsoff!

anupshastri
Автор

But i can implement Abstraction without interface or abstract class. Just a concrete class that hides certain functions and makes public other functions

alxx
Автор

to whom were hiding internally details and showing functionality
This was the interview questions could you plz answer

mdibrahimrazviks
Автор

is there any real life application of making abstract class with all the methods which are concrete, i mean where can we use this concept?

sonalgupta
Автор

How about when both interfaces have a same method name with different return types like int calculate() and Boolean calculate(). Won’t the class implementing it have an ambiguity then?

winiash
Автор

Still don't get what is the use of having an abstract class but there is no abstract method in it?

aakash
Автор

Hi, could you please explain how we achieve security, what we hide, from whom we hide it, and with examples in Java?
As I see abstraction has nothing to do with hiding and security. in my opinion, it's called abstraction because for abstract class we don't provide any concrete details. it is a template for the child's classes

Let's see an example

public abstract class Shape {

public abstract double getArea();

public abstract double getPerimeter();
}

class Circle extends Shape {
private double radius;

public Circle(double radius) {
this.radius = radius;
}

@Override
public double getArea() {
return Math.PI * radius * radius;
}

@Override
public double getPerimeter() {
return 2 * Math.PI * radius;
}
}

class Rectangle extends Shape {
private double width;
private double height;

public Rectangle(double width, double height) {
this.width = width;
this.height = height;
}

@Override
public double getArea() {
return width * height;
}

@Override
public double getPerimeter() {
return 2 * (width + height);
}
}

Now my client wants to use my area calculation app

public class Client {
public static void main(String[] args) {
Shape circle = new Circle(5);
Shape rectangle = new Rectangle(4, 6);

System.out.println("Area of circle: " + circle.getArea());
System.out.println("Perimeter of circle: " + circle.getPerimeter());

System.out.println("Area of rectangle: " + rectangle.getArea());
System.out.println("Perimeter of rectangle: " + rectangle.getPerimeter());
}
}

As we can see there is no security and nothing is hidden via abstraction
1) As instead of Shape class he can directly use Circle or Rectangle :
Circle circle = new Circle(5);
Rectangle rectangle = new Rectangle(4, 6);
2) The methods of Circle or Rectangle are public he can clearly see implementation: no hiding

Now if you make Circle or Rectangle abstract too then you my client can use functionality?

Please anyone clear my doubt

chamanjain
Автор

You said Abstract class can't be instantiated then how it will create an instance 🧐 variable 😅

theWorldOfIss
Автор

Great explenetion but di, you suffering from cold take care

arvinsuryavanshi
Автор

Hi you are nice explain thank s provide the video

praveenxsys