0% found this document useful (0 votes)
2 views

Core Java Interview

The document provides an overview of key concepts in Java, including its definition as a high-level programming language and details about constructors, static variables, the 'this' keyword, aggregation, the 'super' keyword, method overloading, and method overriding. Each concept is briefly explained with examples where applicable. The information is aimed at enhancing understanding of Java programming fundamentals.

Uploaded by

bhamrekashyap
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Core Java Interview

The document provides an overview of key concepts in Java, including its definition as a high-level programming language and details about constructors, static variables, the 'this' keyword, aggregation, the 'super' keyword, method overloading, and method overriding. Each concept is briefly explained with examples where applicable. The information is aimed at enhancing understanding of Java programming fundamentals.

Uploaded by

bhamrekashyap
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

1) What is Java?

Java is the high-level, object-oriented, robust, secure programming language,


platform-independent, high performance, Multithreaded, and portable programming
language. It was developed by James Gosling in June 1991. It can also be known as
the platform as it provides its own JRE and API.

2)What is the constructor?


1.The constructor can be defined as the special type of method that is used to initialize
the state of an object.

2.The name of the constructor must be similar to the class name.

3.The constructor must not have an explicit return type.

3)What is the static variable?


The static variable is used to refer to the common property of all objects (that is not
unique for each object), e.g., The company name of employees, college name of
students, etc. Static variable gets memory only once in the class area at the time of
class loading. Using a static variable makes your program more memory efficient (it
saves memory). Static variable belongs to the class rather than the object.

4)What is this keyword in java?


The this keyword is a reference variable that refers to the current object. There are the
various uses of this keyword in Java. It can be used to refer to current class properties
such as instance methods, variable, constructors, etc. It can also be passed as an
argument into the methods or constructors. It can also be returned from the method
as the current class instance.

5) What is aggregation?
Aggregation can be defined as the relationship between two classes where the
aggregate class contains a reference to the class it owns. Aggregation is best described
as a has-a relationship. For example, The aggregate class Employee having various
fields such as age, name, and salary also contains an object of Address class having
various fields such as Address-Line 1, City, State, and pin-code. In other words, we can
say that Employee (class) has an object of Address class. Consider the following
example.
6) What is super in java?
The super keyword in Java is a reference variable that is used to refer to the immediate
parent class object. Whenever you create the instance of the subclass, an instance of
the parent class is created implicitly which is referred by super reference variable. The
super() is called in the class constructor implicitly by the compiler if there is no super
or this.

7) What is method overloading?


Method overloading is the polymorphism technique which allows us to create multiple
methods with the same name but different signature. We can achieve method
overloading in two ways.

o By Changing the number of arguments


o By Changing the data type of arguments

Method overloading increases the readability of the program. Method overloading is


performed to figure out the program quickly.

8) What is method overriding:


If a subclass provides a specific implementation of a method that is already provided
by its parent class, it is known as Method Overriding. It is used for runtime
polymorphism and to implement the interface methods.

You might also like