• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Abstact class Que

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
abstract class A{
void someMethod(){}
}

class B extends A{
// not abstract, doesn't override the someMethod of A
//
}

Here,is it mandatory for Class B to implement someMethod() ???
Please suggest
 
Ranch Hand
Posts: 479
1
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

Abstract classes can have abstract methods and fully implemented methods. In this case class A does not have any abstract methods that need to be overridden in class B. If you have any abstract methods in A the code will not compile.

Cheers,
Raj.
 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Hemant ,

An abstract class can have both abstract and non-abstract methods .
And FIRST CONCRETE class must implement abstract methods . This rule
does not apply to non-abstract methods .

abstract class Top{
void walk(){}
abstract void flee();
}

class Main extends Top{
public static void main(String... args){
your Code..............
}
void flee(){
System.ou.println("Trying to flee.")
}
}

Here abstract method flee() is implemented but not walk();

Sometimes a class is declared abstract only because we do not want to
instantiate that class . However that class does not has any abstract method . It is valid in Java to declare a class as abstract without having
any abstract method .
[ June 17, 2008: Message edited by: Madhukar Ojha ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic