Hello Friends, In this blog post I am going to let you know about a few more questions of core java related to the OOPS concept, classes, and objects.
Core java interview questions covers all the important questions of the topics mentioned above.
These core java interview questions is a great help to remember all the important highlights and important topics from each java chapter.
These interview questions will surely help to understand a few very confusing concepts in java.
What is object oriented approach?
An object-oriented programming approach is a programming methodology to design computer programs using classes and objects.
What is the difference between a class and an object?
A class is a model for creating objects and does not exist physically, An object is anything that exists physically, both the class and objects contain variable and methods.
What is the difference between object-oriented programming languages and object-based programming languages?
Object-oriented programming languages follow all the features of an object-oriented programming system(OOPS). Smalltalk, Simula-67, java are examples of oops languages.
What is hash code in java?
Hash code is a unique identification number allotted to the objects by the JVM. This hash code number is also called reference number which is created based on the location of the object in memory and is unique for all objects, except for string objects.
Can you declare a class as a private?
No, if we declare a class as private, then it is not available to java compiler and hence a compile-time error occurs, but inner classes can declare as private.
When is a constructor called, before or after creating the object?
A constructor is called concurrently when the object creation is going on. JVM first allocates memory for the object and then executes the constructor to initialize the instance variable. By the time, object creation is completed, the constructor execution is also completed.
What is the difference between the default constructor and parameterized constructor?
The difference between the default constructor and the parameterized constructor is given below.
Default constructor is useful to initialize all objects with same data.
Parameterized constructor is useful to initialize each object with different data.
Default constructor does not have any parameters.
Parameterized constructor will have 1 or more parameter.
When data is not passed at the time of creating an object, default constructor is called.
When data is passed at the time of creating an object, parameterized constructor is called.
What is the difference between constructor and a method In java?
The difference between constructor and a method is given below.
A constructor is used to initialize the instance variables of a class.
A method is used for any general calculation, purpose, or processing.
A constructor’s name and class name should be the same.
A method name and class name can be the same or different.
A constructor is called at the time of creating the object.
A method can be called several times on the object.
A constructor is called and executed automatically.
A method is executed only when we call it.
What is constructor overloading In java?
Writing two or more constructors with the same name but with a difference in the parameters is called constructor overloading. Such constructors are useful to perform different tasks.
So this was all about the Core java interview questions in this topic.
These Core java interview questions could be a great help in your college viva, academic study, and any job interview.
In the case of any queries, you can write to us at [email protected] we will get back to you ASAP.
Hope! you would have enjoyed this post about Core Java Interview Questions Part 8/ OOPS concept, classes, and objects.
Please feel free to give your important feedbacks in the comment section below.
Have a great time!