Skip to main content

Abstract class in Java

Java Programming

Abstract class in Java

A class that is declared with abstract keyword, is known as abstract class. Before learning abstract class, let's understand the abstraction first.


Abstraction 

Abstraction is a process of hiding the implementation details and showing only functionality to the user.

Ways to achieve Abstraction 

There are two ways to achieve abstraction in JAVA
1. Abstract class (0 to 100%) 
2. Interface (100%) 

Example

abstract class Bike
 {
     abstract void run();
 }
class Honda extends Bike 
{
   void run()
 {
 System.out.println("running safely..");
 }
      public static void main(String args[])
 {
    Bike obj = new Honda();    obj.run();   
 }

Comments

Popular posts from this blog

DIFFRENCE BETWEEN JAVA AND C++

Java Programming JAVA :- 1. Java is true Object oriented language. 2. Java does not support operator overloading. 3. It supports labels with loops and statement blocks . 4. Java does not have template classes as in C++. 5. Java compiled into byte code for the Java Virtual Machine. The source code is independent   on operating system. 6. Java does not support multiple inheritance of classes but it supports interface. 7. Runs in a protected virtual machine. 8 . Java does not support global variable. Every variable should declare in class. 9.  Java does not use pointer. 10. It Strictly enforces an object oriented Programming paradigm. C++ :- 1. C++ is basically C with Object-oriented extension. 2. C++ supports operator overloading. 3. It supports go to statement. 4. C++ has template classes. 5. Source code can be written to be platform independent C++ typically compiled into machine code. 6. C++ supports multiple inheritance ...