is it possible to use a method of an abstract class?
how can i use a method of a class without having an instance?
is it possible to use a method of an abstract class? how can i
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you declare a method as
static, you can call it directly without needing a class instance. Otherwise you will need to have an instance of a derived class.Since an abstract class cannot be instantiated directly, you cannot call a method of an abstract class directly unless it is a static method. But you can call a static method of an abstract class directly, here is a quick example:
Alternatively, if you have an instance of a class that is derived from an abstract class, you can treat it as an instance of the abstract class, and can call any methods on it.