Core java interview questions And Answer
is the difference between procedural and object-oriented programs?
Ans: The difference between procedural and object-oriented programs
a) In procedural program, programming logic follows certain procedures and the
instructions are executed one after another. In OOP program, unit of program is
object, which is nothing but combination of data and code
b) In procedural program, data is exposed to the whole program whereas in OOPs
program, it is accessible with in the object and which in turn assures the
security of the code.
Q2.What are Encapsulation, Inheritance and Polymorphism?
Ans: Encapsulation is the mechanism that binds together code
and data it manipulates and keeps both safe from outside interference and
Inheritance is the process by which one object acquires the
properties of another object.
Polymorphism is the feature that allows one interface to be
used more than one calss.In other world we can say polymorphism is a reusability
of object in more than one class.
Q3.What is the difference between Assignment and Initialization?
Ans: Assignment can be many times as desired whereas
initialization can be only once.
Q4.What is OOPs?
Ans: Object oriented programming organizes a program around
its data, i. e. , objects and a set of well defined interfaces to that data. An
object-oriented program can be characterized as data controlling access to code.
Q5.What are Class, Constructor and Primitive data types?
Ans: Class is a template for multiple objects with similar
features and it is a blue print for objects. It defines a type of object
according to the data the object can hold and the operations the object can
Constructor is a special kind of method that determines how an
object is initialized when created. The name of constructor is same as class
name. Primitive data types are 8 types and they are: byte, short, int, long,
float, double, Boolean, char.
Q6.What is an Object and how do you allocate memory to it?
Ans: Object is an instance of a class and it is a software
unit that combines a structured set of data with a set of operations for
inspecting and manipulating that data. The object is created by using new
keyword. When an object is created using new operator, memory is allocated to
Q7.What is the difference between constructor and method?
Ans: Constructor will be automatically invoked when an object is
created whereas method has to be called explicitly by using
dot(.) operator .
Q8:What are methods and how are they defined?
Ans: Methods are functions that operate on instances of classes in
which they are defined. By use of the method objects can communicate with each
other and can call methods in other classes. Method definition has four parts.
They are name of the method, type of object or primitive type the method
returns, a list of parameters and the body of the method. A methodís signature
is a combination of the first three parts mentioned above.
Q9:What is the use of bin and lib in JDK?
Ans: Bin contains all tools such as javac, appletviewer, awt
tool, etc., whereas lib contains API and all packages.
Q10: What is casting?
Ans: Casting is process of convert the value of one type to another.
Q11: How many ways can an argument be passed to a subroutine and
Ans: An argument can be passed in two ways. They are passing by
value and passing by reference.
Passing by value: This method copies the value of an argument
into the formal parameter of the subroutine.
Passing by reference: In this method, a reference to an argument (not
the value of the argument) is passed to the parameter.
Q12:What is the difference between an argument and a parameter?
Ans: At time of defining method, variables passed in the method are
At time of using those methods, values passed to those variables are called
Core java interview
questions And Answer
Show All Comments