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


Please Help Members By Posting Answers For Below Questions

what state does a thread enter when it terminates its processing? : Java thread

592


Under what conditions is an object’s finalize() method invoked by the garbage collector?

573


Is there any tag in htm to upload and download files?

604


Who found java?

547


What are peerless components?

616






What happens if an exception is throws from an object's constructor?

621


What is logical variable?

504


How many bytes is a string?

556


What is member in java?

484


How do you declare a string variable?

512


Explain the importance of finally block in java?

566


What classes of exceptions may be caught by a catch clause in java programming?

696


Can abstract class have private constructor?

494


What is java english?

489


Does java trim remove newline?

536