• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Abstraction Example

 
Jdinesh Tiwari
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, and thanks in advance to all I tried to implement this example to learn scenario of abstraction practically ? But I am facing 9 nos. of compile time error ? Whats the problem with this code

abstract ClassA{
int x,y;
void method(int x, int y)
{}
abstract void method2();
abstract void method3();
}
ClassB extends ClassA{
void method2()
{
System.out.println("this is Method 2 of class B");
}
void method3()
{
System.out.println("this is Method 3 of class B");
}
}
ClassC extends ClassA{
void method2()
{
System.out.println("this is Method 2 of class C");
}
void method3()
{
System.out.println("this is method 3 of class C");
}
}

public class MainClass {
public static void main(String[]args){

ClassA obj1 = new ClassB();
obj1.method2();
obj1.method3();

ClassA obj2 = new ClassC();
obj2.method2();
obj2.method3();
}
}
 
M Mohile
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It should be abstract class ClassA and not abstract ClassA. Similarly, follow the same for ClassB and ClassC..Hope this helps..
 
shakil ahamad
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We better have a good quality performance testing.website performance test
 
Jdinesh Tiwari
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Mohile, Thank you
 
M Mohile
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My pleasure.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic