• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Abstraction Example

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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();
}
}
 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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..
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Mohile, Thank you
 
M Mohile
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My pleasure.
 
A "dutch baby" is not a baby. But this tiny ad is baby sized:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic