+ 1

Guys who can explain more about abstraction?

24th Aug 2016, 8:58 PM
Thoriso Seitatolo
Thoriso Seitatolo - avatar
2 Réponses
+ 1
An abstract class in simple words is a class that has one abstract method or more without implementation. The abstract method should be implemented by the subclasses ex: abstract class Food{ public static final int FRUIT=1; public static final int VEG=2; public abstract int getType(); public void eat(){ System.out.println("eating...yummy"); } } class Fruit extends Food { public int getType(){ return Food.FRUIT; } } public class Program { public static void main(String[] args) { Fruit f = new Fruit(); f.eat(); if(f.getType() == Food.VEG){ System.out.print("Vegetable"); }else{ System.out.print("Fruit"); } } }
25th Aug 2016, 8:56 AM
Tiger
Tiger - avatar
0
abstract class in simple word contain method without body define in super class and method declared in subclass
22nd Oct 2016, 4:45 PM
balram sao
balram sao - avatar