Upload
rangeet-pan
View
215
Download
0
Embed Size (px)
Citation preview
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
1/64
Miscellaneous Interviewuestions
For CSE and IT
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
2/64
Interview Questions What is synchronization and why is it
important?
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
3/64
Answer With respect to multithreading,
synchronization is the capability to control theaccess of multiple threads to shared
. ,possible for one thread to modify a sharedobject while another thread is in the process
of using or updating that object's value
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
4/64
Question Does garbage collection guarantee that a
program will not run out of memory?
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
5/64
Answer Garbage collection does not guarantee that a
program will not run out of memory. It ispossible for programs to use up memory
collected. It is also possible for programs tocreate objects that are not subject to garbage
collection
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
6/64
Question What value does readLine() return when it
has reached the end of a file?
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
7/64
Answer The readLine() method returns null when it
has reached the end of a file.
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
8/64
Question To what value is a variable of the String type
automatically initialized?
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
9/64
Answer The default value of an String type is null.
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
10/64
Question What class is the top of the AWT event
hierarchy?
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
11/64
Answer The java.awt.AWTEvent class is the highest-
level class in the AWT event-class hierarchy.
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
12/64
Question When a thread is created and started, what is
its initial state?
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
13/64
Answer A thread is in the ready state after it has been
created and started.
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
14/64
Question What is the range of the short type?
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
15/64
Answer The range of the short type is -(2^15) to
2^15 - 1.
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
16/64
Question What is the range of the char type?
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
17/64
Answer The range of the char type is 0 to 2^16 - 1.
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
18/64
Question What is the purpose of finalization?
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
19/64
Answer The purpose of finalization is to give an
unreachable object the opportunity toperform any cleanup processing before the
.
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
20/64
Question What is the difference between the Boolean
& operator and the && operator?
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
21/64
Answer If an expression involving the Boolean & operator
is evaluated, both operands are evaluated. Thenthe & operator is applied to the operand. Whenan expression involving the && operator iseva ua e , e rs operan s eva ua e . efirst operand returns a value of true then thesecond operand is evaluated. The && operator isthen applied to the first and second operands. If the first operand evaluates to false, theevaluation of the second operand is skipped.
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
22/64
Question What is the purpose of the Runtime class?
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
23/64
Answer The purpose of the Runtime class is to provide
access to the Java runtime environment
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
24/64
Question How many times may an object's finalize()
method be invoked by the garbage collector?
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
25/64
Answer An object's finalize() method may only be
invoked once by the garbage collector.
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
26/64
Question What is the argument type of a Java
program's main() method?
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
27/64
Answer A program's main() method takes an
argument of the String[] type.
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
28/64
Question What must a class do to implement an
interface?
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
29/64
Answer It must provide all of the methods in the
interface and identify the interface in itsimplements clause.
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
30/64
Question What is the difference between the
Reader/Writer class hierarchy andthe InputStream/OutputStream class
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
31/64
Answer The Reader/Writer class hierarchy is
character-oriented, and theInputStream/OutputStream class hierarchy is
- .
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
32/64
Question If a class is declared without any access
modifiers, where may the class be accessed?
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
33/64
Answer A class that is declared without any access
modifiers is said to have package access. Thismeans that the class can only be accessed by
within the same package.
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
34/64
Question Name the eight primitive Java types.
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
35/64
Answer The eight primitive types are byte, char, short,
int, long, float, double, and boolean.
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
36/64
Question What is the difference between the paint()
and repaint() methods?
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
37/64
Answer The paint() method supports painting via a
Graphics object. The repaint() method is usedto cause paint() to be invoked by the AWT
.
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
38/64
Question If a method is declared as protected, where
may the method be accessed?
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
39/64
Answer A protected method may only be accessed by
classes or interfaces of the same package orby subclasses of the class in which it is
.
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
40/64
Question What is Reference Variable?
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
41/64
Answer Reference variable provides an alternative
name for previously defined variable.
Data_type re erence_name =variable_name
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
42/64
Question What are the advantages of new operator
over malloc()?
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
43/64
Answer It automatically computes the size of the data
object. So we dont need the sizeof operator. It automatically returns the correct pointer
. It is possible to initialize the object while
creating the memory space. Like any other operator new can be
overloaded
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
44/64
Question What is endl and setw?
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
45/64
Answer endl: it is a manipulator, when used in the
output statement, causes a linefeed to beinserted.
setw: it is also a manipulator to make theoutput right justified.
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
46/64
Question What is inline function?
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
47/64
Answer When we call a function then control jumps to
the function and come back to the callingfunction after execution. It take lots of time.
,function the compiler replaces the functioncall with the corresponding function code but
control not jump to function.
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
48/64
Question What happens if we add the static keyword
before a method?
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
49/64
Answer
A static method can have access to only other
static members. A static member function can be called using
.
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
50/64
Question
What are the characteristics of a constructor?
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
51/64
Answer
The name of the constructor must be same as
the class name The constructor is declared with no return
Constructor may not be static It cant be inherited
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
52/64
Question
What is the difference between class and
structure?
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
53/64
Answer
Structure: Initially (in C) a structure was used
to bundle different type of data typestogether to perform a particular functionality.But C++ extended the structure to contain
functions also. The major difference is that alldeclarations inside a structure are by defaultpublic.Class: Class is a successor of Structure. Bydefault all the members inside the class areprivate.
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
54/64
Question
What is friend function?
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
55/64
Answer As the name suggests, the function acts as a
friend to a class. As a friend of a class, it canaccess itsprivate and protected members. A friend functions no a mem er o e c ass. u mus e s e
in the class definition. A non membered function which declared in class
defination through which we can access theprivate and protected data members of a class iscalled a friend function.
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
56/64
Question
What is virtual base class?
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
57/64
Answer
When we declare a class as virtual, then only
one copy of that class can be inherited,regardless of how many objects are sharing.
Q i
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
58/64
Question
What is virtual function?
Q i
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
59/64
Question
What is seekg(), seekp(), tellg(), and tellp()?
A
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
60/64
Answer
seekg(): moves the file pointer (input) to a
specified location seekp(): moves the file pointer (output) to a
tellg(): gives the current position of the getpointer
tellp(): gives the current position of the putpointer.
Q ti
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
61/64
Question
How many operator do we have in C?
A
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
62/64
Answer
Arithmetic Relational Logical
Increment and decrement Assignment Conditional Bitwise
Q estion
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
63/64
Question
What are the string handling functions
present in C?
Answer
8/4/2019 Miscellaneous Interview Questions [Compatibility Mode]
64/64
Answer
strlen() strcpy() strcat()
strcmp()