Code Snippets in JAVA Programming and their OUTPUTS-Day 3
CODE SNIPPETS OUTPUT
ABSTRACT CLASSES AND METHODS
Concept: Abstract classes and methods - A class that has at least one abstract method is
known as an abstract class and should be qualified using the...
More
Code Snippets in JAVA Programming and their OUTPUTS-Day 3
CODE SNIPPETS OUTPUT
ABSTRACT CLASSES AND METHODS
Concept: Abstract classes and methods - A class that has at least one abstract method is
known as an abstract class and should be qualified using the keyword abstract
abstract class Test
{
abstract void show();
void next()
{
System.
out.
println("Hello");
}
public static void main (String [] args)
{
System.
out.
println("You are in an abstract class");
}
}
You are in an abstract
class
Question: If there are no abstract methods, can a class be declared ‘abstract’? Answer: Yes
abstract class Test
{
void next()
{
System.
out.
println("Hello");
}
public static void main (String [] args)
{
System.
out.
println("You are in an abstract class");
}
}
You are in an abstract
class
Question: What if one method is abstract but the class is not ‘abstract’? Answer: Error
Less