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
how we can use debug in myeclipse 6.0 in order solve the problems that exist in our program when there are 900 to 1000 pages in a web application
What is the transient keyword?
What mechanism does java use for memory management?
What is JDBC Driver interface?How can you retrieve data from the ResultSet
what is collatration?
Define how destructors are defined in java?
What is outofmemoryerror in java?
What does the three dot emoji mean?
How to instantiate static nested classes in java?
Can we override private method in java?
What is difference between public static and void?
How many bytes is double?
What do you understand by the term string pool?
What is the difference between instanceof and isinstance?
What is a bufferedreader?