Frequently Asked Java Questions in Interviews
Frequently Asked Java Questions in Interviews
com
+1-732-546-3607
1) 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.
2) What is the difference between Procedural and OOPs?
Ans: a) In procedural program, programming logic follows certain procedures and
the instructions are executed
one after another. In OOPs 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.
3) 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 misuse.
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 for general class
actions.
http://www.p2cinfotech.com
+1-732-546-3607
http://www.p2cinfotech.com
+1-732-546-3607
http://www.p2cinfotech.com
+1-732-546-3607
http://www.p2cinfotech.com
+1-732-546-3607
http://www.p2cinfotech.com
+1-732-546-3607
http://www.p2cinfotech.com
+1-732-546-3607
garbage collection.
finally : finally, a key word used in exception handling, creates a block of code that
will be executed after a
try/catch block has completed and before the code following the try/catch block.
The finally block will
Page 3 of 38 3 execute whether or not an exception is thrown.
For example, if a method opens a file upon exit, then you will not want the code that
closes the file
to be bypassed by the exception-handling mechanism. This finally keyword is
designed to address this
contingency.
15) What is UNICODE?
Ans: Unicode is used for internal representation of characters and strings and it uses
16 bits to represent each
other.
16) What is Garbage Collection and how to call it explicitly?
Ans: When an object is no longer referred to by any variable, java automatically
reclaims memory used by that
object. This is known as garbage collection.
System.gc() method may be used to call it explicitly.
17) What is finalize() method ?
Ans: finalize( ) method is used just before an object is destroyed and can be called
just prior to garbage collection.
18) What are Transient and Volatile Modifiers?
Ans: Transient : The transient modifier applies to variables only and it is not stored
as part of its objects
persistent state. Transient variables are not serialized.
Volatile : Volatile modifier applies to variables only and it tells the compiler that the
variable modified by
volatile can be changed unexpectedly by other parts of the program.
http://www.p2cinfotech.com
+1-732-546-3607
http://www.p2cinfotech.com
+1-732-546-3607
P2Cinfotech is one of the leading, Online IT Training facilities and Job Consultant, spread all
over the world. Provide quality online training for QA, QTP, Manual Testing, HP LoadRunner,
BA, Java Technologies, SEO, Web Technologies, .NET, Oracle DBA etc.
http://www.p2cinfotech.com
+1-732-546-3607