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. give an recursive example using string
View Tutorial          By: sauk at 2011-08-22 16:16:41

2. this is really helpful example for Learning RMS in
View Tutorial          By: Ahmed Nawaz Mari at 2011-06-30 05:29:18

3. hello!
I am so confused and a total beginne

View Tutorial          By: Jena at 2011-06-11 17:39:39

4. Excellent.
Just one question... What is the

View Tutorial          By: HeilGates at 2010-08-04 13:38:12

5. that was useful to me, thank you so much .
View Tutorial          By: ahmed at 2010-01-11 15:59:42

6. Thanks dear
View Tutorial          By: Muthin at 2009-04-29 00:32:24

7. Thank you! :) But I have a question, why is that t
View Tutorial          By: choco at 2010-01-03 02:16:18

8. hi everbody. i need to extract a output from one j
View Tutorial          By: keerthi at 2010-10-29 13:38:28

9. Your script works beautifully. Is there a way to i
View Tutorial          By: JW at 2013-05-08 22:22:44

10. Thanks a lot lot lot for this... u saved me...
View Tutorial          By: Sourabh Idoorkar at 2011-06-10 04:25:10