Is it compulsory to have atleast one abstract method in
abstract class?
Answer Posted / jatin
NO,It is not mandatory to write abstract members in Abstract
Class. I Repeat <IT IS NOT MANDATORY> ,If anyone have doubt
regarding this than simply make a program then everything
will be cleared, FOR YOUR CLARIFICATION I AM MAKING 1 SIMPLE
PROGRAMME FOR U GUYS
HOPE U WILL ENJOY AFTER READING THIS ..
program in console application:
namespace ConsoleApplication1
abstract class absClass
{
//A Non abstract method
protected virtual int AddTwoNumbers(int a, int b)
{
return a + b;
}
}
class absDerived : absClass
{
protected override int AddTwoNumbers(int Num1, int Num2)
{
int n = Num1 + Num2;
Console.WriteLine("sum of method is:" + n);
return n;
}
static void Main()
{
//You can create an
//instance of the derived class
absDerived calculate = new absDerived();
int sum = calculate.AddTwoNumbers(10, 20);
Console.WriteLine("{0}", sum);
Console.Read();
}
}
}
All the best ... :)
| Is This Answer Correct ? | 4 Yes | 2 No |
Post New Answer View All Answers
What is nested loop? What is dangling else condition in it?
What are assembly attributes?
Difference between start() and run() method of thread class?
What is bitwise complement?
Which types of exceptions are caught at compile time?
What is difference between static class and normal class?
What is the difference between Grid and Gridbaglayout?
How is java created?
Is it possible for a yielded thread to get chance for its execution again?
What does snprintf return?
What is polymorphism in java? What are the kinds of polymorphism?
What’s meant by anonymous class?
Define the term string pool?
What is passing value java?
What is the difference between call by reference and call by pointer?