Core Java - Interview Questions and Answers for 'Base class' - 2 question(s) found - Order By Newest Q1. Difference between Base Class, Derived Class , Abstract Class and Concrete Class ? Core Java
Ans. Base Class is a relative term used to signify the Parent class in Parent - Child or Base - derived relationship.
Derived Class is a relative term used to signify the Child class in Parent - Child or Base - derived relationship.
Abstract Class is a class that is not allowed to be instantiated and hence can serve only a base class for it's usage.
Concrete Class is the class which is supposed to be instantiated and hence provide definition for all implementing interface methods and extending abstract methods. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Base Class   Derived Class   Abstract Class   Concrete ClassRelated Questions Differences between abstract class and interface ? Difference between Abstract and Concrete Class ? If an Abstract class has only abstract methods, What's the difference between such a class and an interface ? What are the design considerations while making a choice between using interface and abstract class ? How is Abstraction implemented in Java ? Why can't we create an instance of abstract class ? Why is it restricted by compiler ? What is an abstract class ? Shall we use abstract classes or Interfaces in Policy / Strategy Design Pattern ? Will this code Work ? If not , Why ? Q2. What is the relationship between Base Class and Abstract Class ? Core Java
Ans. Abstract Class is a class that's only allowed to be a Base class for it's usage. It can never be instantiated on it's own. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  base class  abstract class basic Related Questions Difference between Base Class, Derived Class , Abstract Class and Concrete Class ? If there is a conflict between Base Class Method definition and Interface Default method definition, Which definition is Picked ? What will happen if there is a default method conflict as mentioned above and we have specified the same signature method in the base class instead of overriding in the existing class ? If a method definition has been specified in Class , its Base Class , and the interface which the class is implementing, Which definition will be picked if we try to access it using Interface Reference and Class object ? If a method definition has been specified in the Base Class and the interface which the class is implementing, Which definition will be picked if we try to access it using Interface Reference and Class object ? Will it print the message in Base Class constructor if we execute main method of Main class ? why ?
public class BaseClass {
BaseClass(){
System.out.println("Hello I am in Base Class Constructor");
}
}
public class DerivedClass extends BaseClass{
}
public class Main {
public static void main(String[] args) {
DerivedClass derivedClass = new DerivedClass();
}
} What will the following print upon executing main method of Main class ?
public class BaseClass {
BaseClass(){
System.out.println("Hello I am in Base Class Constructor");
}
}
public class DerivedClass extends BaseClass{
DerivedClass(){
System.out.println("Hello I am in Derived Class Constructor");
}
}
public class Main {
public static void main(String[] args) {
DerivedClass derivedClass = new DerivedClass();
}
} What will the following code print upon executing main method of Main class ?
public class BaseClass {
BaseClass(){
System.out.println("Hello I am in Base Class Constructor");
}
}
public class DerivedClass extends BaseClass{
DerivedClass(){
System.out.println("Hello I am in Derived Class Constructor");
super();
}
}
public class Main {
public static void main(String[] args) {
DerivedClass derivedClass = new DerivedClass();
}
}
What will the following code print upon executing main method of Main class ?
public class BaseClass {
BaseClass(int x){
System.out.println("Hello I am in Base Class Constructor");
}
}
public class DerivedClass extends BaseClass{
DerivedClass(){
System.out.println("Hello I am in Derived Class Constructor");
}
}
public class Main {
public static void main(String[] args) {
DerivedClass derivedClass = new DerivedClass();
}
} What will the following code print upon executing main method of Main class ?
public class BaseClass {
BaseClass(int x){
System.out.println("Hello I am in Base Class Constructor");
}
}
public class DerivedClass extends BaseClass{
DerivedClass(){
super(1);
System.out.println("Hello I am in Derived Class Constructor");
}
}
public class Main {
public static void main(String[] args) {
DerivedClass derivedClass = new DerivedClass();
}
}