Comment on Tutorial - Abstract classes in Java By Kamini

Comment Added by : Pulkit Malviya

Comment Added at : 2012-08-26 14:56:18

Comment on Tutorial : Abstract classes in Java By Kamini
Hello to Every one!! :-),HERE I'AM NOT WRITING A CODE BECZ IT WILL TAKE A LOTS OF SPACE,SO I'AM JUST GIVING EXPLANATIONS TAT WAT IS ABSTRACT CLASS,BUT AFTER READING DIS EXPLANATIONS ALSO IF NYONE WILL NOT UNDERSTAND THEN AFTER TAT I'LL WRITE D CODE ALSO,so firstly we'll go to the "Abstract Method" before "Abstract Class,so wat is Abstract method?? so Method u all know is like a fucntion in C++ or C,just name is changed otherwise no differences r der,so "abstract method is a method without body",an abstract method is written when d same method has to perform different tasks depending on the object calling it,nd "ABSTRACT CLASS is a class tat contains 0 or more abstract methods, i mean in other words for Eg- if we want to calculate the square value in a Java program,so let we took a function named "calculate()" nd class named"Myclass" in a program,nd after tat we provide body for calculate() method,also we took three objects named obj1,obj2,obj3,now after dis u all r already know how to write a program of square value,actualy i'am not concentrating on square value program,i'am concentrating on the "BODY" of calculate() method,dis means as we written a body for calculate() method,so tat it is commonly available to all d objects -obj1,obj2,obj3,means requirements of all d objects is same,i.e "to calculate the square value",but sometimes the requirements of all d objects will be different depending on the objects,for eg-like first object(obj1) wants to calculate square value,second object(obj2) wants the square root value,nd third object(obj3) wants cube value,then wat to do now??its simple,firstly just write a calculate() method in "Myclass",dis means every object wants to calculate something,after tat dont write body for calculate() method,so tat it will not be commonly available to all d objects-obj1,obj2,obj3,so such a method is called as a "Abstract Method",in dis way we write abstract method in Myclass,then it is called as "Abstract Class",now derive sub classes from Myclass,tat means firstly derive sub class Sub1 from Myclass,so tat the calculate() method is available to d sub class,now provide a body for calculate() method in sub1 so tat it calculates square value,//ly we create another sub class Sub2 ,where we write the calculate() method with body to calculate square root value,then we again create d third sub class Sub3 where we write the calculate() method to calculate cube value,in dis way we'll create sub classes,nd after tat in another class u all r already know tat how to create sub class objects to call these classes methods,like Sub1 obj1=new Sub1(); Sub2 obj2=new Sub2();Sub3 obj3=new Sub3(); now after tat these objects will call,like dis- obj1.calculate(4);//calculate square,obj2.calculate(16); // calculate square root,obj3.calculate(3); // calculate cube value,so frnds the main concentration was on the "METHOD BODY",so in short "abstract method is a method without method body nd is written when the same method has to perform different tasks depending on the object" nd "abstract class is a class tat contains abstract methods",thanx,i'am waiting for ur comments... :-)

View Tutorial

Subscribe to Tutorials

Related Tutorials

Program using concept of byte long short and int in java

Update contents of a file within a jar file

Tomcat and httpd configured in port 8080 and 80

Java File

Java String

Count number of vowels, consonants and digits in a String in Java

Reverse a number in Java

Student marks calculation program in Java

Handling Fractions in Java

Calculate gross salary in Java

Calculate average sale of the week in Java

Vector in Java - Sample Program

MultiLevel Inheritance sample in Java

Multiple Inheritance sample in Java

Java program using Method Overriding

Archived Comments

1. How do u edit the text ? this is always replacing
View Tutorial          By: anurag at 2012-08-23 07:24:47

2. thanks 4 d inf..
View Tutorial          By: Ankur Saxena at 2012-02-10 15:31:33

3. its not solve my problem.i.e
the concept is

View Tutorial          By: murli at 2010-10-02 23:23:11

4. Thanks so much for the tutorial!! Was extremely us
View Tutorial          By: Debarupa at 2012-05-10 20:23:28

5. How to execute above sqlstr file.
View Tutorial          By: shriyash at 2014-02-23 09:32:36

6. Looks good. This is going to be a good resource.
View Tutorial          By: Brainpower at 2013-03-02 02:45:11

7. its superb
View Tutorial          By: chotu jain at 2011-05-24 08:47:22

8. worked for me thanks.
View Tutorial          By: dem125 at 2010-08-03 23:30:32

9. Good one. Clear basic concept
View Tutorial          By: Joshua at 2010-03-12 01:13:08

10. This has tread error , copy and paster hole code a
View Tutorial          By: Daniel at 2015-01-21 16:24:36