Вы находитесь на странице: 1из 30

JAVA INTERVIEW QUESTIONS

1. What is a transient variable?


A transient variable is a variable that may not be serialized.

2. Which containers use a border Layout as their default layout?


The window, Frame and Dialog classes use a border layout as their default layout.

3. Why do threads block on I/O?


Threads block on I/O (that is enters the waiting state) so that other threads may execute while the I/O Operation is performed.

4. How are Observer and Observable used?


Objects that subclass the Observable class maintain a list of observers. When an Observable object is updated it invokes the update()
method of each of its observers to notify the observers that it has changed state. The Observer interface is implemented by objects that
observe Observable objects.

5. What is synchronization and why is it important?


With respect to multithreading, synchronization is the capability to control the access of multiple threads to shared resources. Without
synchronization, it is possible for one thread to modify a shared object while another thread is in the process of using or updating that
object's value. This often leads to significant errors.

6. Can a lock be acquired on a class?


Yes, a lock can be acquired on a class. This lock is acquired on the class's Class object.

7. What's new with the stop(), suspend() and resume() methods in JDK 1.2?
The stop(), suspend() and resume() methods have been deprecated in JDK 1.2.
8. Is null a keyword?
The null value is not a keyword.

9. What is the preferred size of a component?


The preferred size of a component is the minimum component size that will allow the component to display normally.

10. What method is used to specify a container's layout?


The setLayout() method is used to specify a container's layout.

11. Which containers use a FlowLayout as their default layout?


The Panel and Applet classes use the FlowLayout as their default layout.

12. What state does a thread enter when it terminates its processing?
When a thread terminates its processing, it enters the dead state.

13. What is the Collections API?


The Collections API is a set of classes and interfaces that support operations on collections of objects.

14. which characters may be used as the second character of an identifier, but not as the first character of an identifier?
The digits 0 through 9 may not be used as the first character of an identifier but they may be used after the first character of an identifier.
15. What is the List interface?
The List interface provides support for ordered collections of objects.

16. How does Java handle integer overflows and underflows?


It uses those low order bytes of the result that can fit into the size of the type allowed by the operation.

17. What is the Vector class?


The Vector class provides the capability to implement a growable array of objects
18. What modifiers may be used with an inner class that is a member of an outer class?
A (non-local) inner class may be declared as public, protected, private, static, final, or abstract.

19. What is an Iterator interface?


The Iterator interface is used to step through the elements of a Collection.

20. What is the difference between the >> and >>> operators?
The >> operator carries the sign bit when shifting right. The >>> zero-fills bits that have been shifted out.

21. Which method of the Component class is used to set the position and size of a component?
setBounds()
22. How many bits are used to represent Unicode, ASCII, UTF-16, and UTF-8 characters?
Unicode requires 16 bits and ASCII require 7 bits. Although the ASCII character set uses only 7 bits, it is usually represented as 8 bits. UTF-8
represents characters using 8, 16, and 18 bit patterns. UTF-16 uses 16-bit and larger bit patterns.

23 What is the difference between yielding and sleeping?


When a task invokes its yield() method, it returns to the ready state. When a task invokes its sleep() method, it returns to the waiting state.

24. Which java.util classes and interfaces support event handling?


The EventObject class and the EventListener interface support event processing.

25. Is sizeof a keyword?


The sizeof operator is not a keyword.

26. What are wrapper classes?


Wrapper classes are classes that allow primitive types to be accessed as objects.

27. Does garbage collection guarantee that a program will not run out of memory?
Garbage collection does not guarantee that a program will not run out of memory. It is possible for programs to use up memory resources
faster than they are garbage collected. It is also possible for programs to create objects that are not subject to garbage collection.

28. What restrictions are placed on the location of a package statement within a source code file?
A package statement must appear as the first line in a source code file (excluding blank lines and comments).
29. Can an object's finalize() method be invoked while it is reachable?
An object's finalize() method cannot be invoked by the garbage collector while the object is still reachable. However, an object's finalize()
method may be invoked by other objects.

30. What is the immediate superclass of the Applet class?


Panel

31. What is the difference between preemptive scheduling and time slicing?
Under preemptive scheduling, the highest priority task executes until it enters the waiting or dead states or a higher priority task comes
into existence. Under time slicing, a task executes for a predefined slice of time and then reenters the pool of ready tasks. The scheduler
then determines which task should execute next, based on priority and other factors.

32. Name three Component subclasses that support painting.


The Canvas, Frame, Panel, and Applet classes support painting.

33. What value does readLine() return when it has reached the end of a file?
The readLine() method returns null when it has reached the end of a file.

34. What is the immediate superclass of the Dialog class?


Window.

35. What is clipping?


Clipping is the process of confining paint operations to a limited area or shape.
36. What is a native method?
A native method is a method that is implemented in a language other than Java.

37. Can a for statement loop indefinitely?


Yes, a for statement can loop indefinitely. For example, consider the following:
for(;;) ;

38. What are order of precedence and associativity, and how are they used?
Order of precedence determines the order in which operators are evaluated in expressions. Associatity determines whether an expression
is evaluated left-to-right or right-to-left

39. When a thread blocks on I/O, what state does it enter?


A thread enters the waiting state when it blocks on I/O.

40. To what value is a variable of the String type automatically initialized?


The default value of a String type is null.

41. What is the catch or declare rule for method declarations?


If a checked exception may be thrown within the body of a method, the method must either catch the exception or declare it in its throws
clause.

42. What is the difference between a MenuItem and a CheckboxMenuItem?


The CheckboxMenuItem class extends the MenuItem class to support a menu item that may be checked or unchecked.
43. What is a task's priority and how is it used in scheduling?
A task's priority is an integer value that identifies the relative order in which it should be executed with respect to other tasks. The
scheduler attempts to schedule higher priority tasks before lower priority tasks.

44. What class is the top of the AWT event hierarchy?


The java.awt.AWTEvent class is the highest-level class in the AWT event-class hierarchy.

45. When a thread is created and started, what is its initial state?
A thread is in the ready state after it has been created and started.

46. Can an anonymous class be declared as implementing an interface and extending a class?
An anonymous class may implement an interface or extend a superclass, but may not be declared to do both.

47. What is the range of the short type?


The range of the short type is -(2^15) to 2^15 - 1.

48. What is the range of the char type?


The range of the char type is 0 to 2^16 - 1.

49. In which package are most of the AWT events that support the event-delegation model defined?
Most of the AWT-related events of the event-delegation model are defined in the java.awt.event package. The AWTEvent class is defined in
the java.awt package.
50. What is the immediate superclass of Menu?
MenuItem

51. What is the purpose of finalization?


The purpose of finalization is to give an unreachable object the opportunity to perform any cleanup processing before the object is garbage
collected.

52. Which class is the immediate superclass of the MenuComponent class.


Object
53. What invokes a thread's run() method?
After a thread is started, via its start() method or that of the Thread class, the JVM invokes the thread's run() method when the thread is
initially executed.

54. What is the difference between the Boolean & operator and the && operator?
If an expression involving the Boolean & operator is evaluated, both operands are evaluated. Then the & operator is applied to the
operand. When an expression involving the && operator is evaluated, the first operand is evaluated. If the first operand returns a value of
true then the second operand is evaluated. The && operator is then applied to the first and second operands. If the first operand evaluates
to false, the evaluation of the second operand is skipped.

55. Name three subclasses of the Component class.


Box.Filler, Button, Canvas, Checkbox, Choice, Container, Label, List, Scrollbar, or TextComponent

56. What is the GregorianCalendar class?


The GregorianCalendar provides support for traditional Western calendars.
57. Which Container method is used to cause a container to be laid out and redisplayed?
validate()

58. What is the purpose of the Runtime class?


The purpose of the Runtime class is to provide access to the Java runtime system.

59. How many times may an object's finalize() method be invoked by the 
garbage collector?
An object's finalize() method may only be invoked once by the garbage collector.

60. What is the purpose of the finally clause of a try-catch-finally statement?


The finally clause is used to provide the capability to execute code no matter whether or not an exception is thrown or caught.

61. What is the argument type of a program's main() method?


A program's main() method takes an argument of the String[] type.

62. Which Java operator is right associative?


The = operator is right associative.

63. What is the Locale class?


The Locale class is used to tailor program output to the conventions of a particular geographic, political, or cultural region.64. Can a double
value be cast to a byte?
Yes, a double value can be cast to a byte.

65. What is the difference between a break statement and a continue statement?
A break statement results in the termination of the statement to which it applies (switch, for, do, or while). A continue statement is used to
end the current loop iteration and return control to the loop statement.

66. What must a class do to implement an interface?


It must provide all of the methods in the interface and identify the interface in its implements clause.

67. What method is invoked to cause an object to begin executing as a separate thread?
The start() method of the Thread class is invoked to cause an object to begin executing as a separate thread.

68. Name two subclasses of the TextComponent class.


TextField and TextArea

69. What is the advantage of the event-delegation model over the earlier event-inheritance model?
The event-delegation model has two advantages over the event-inheritance model. First, it enables event handling to be handled by
objects other than the ones that generate the events (or their containers). This allows a clean separation between a component's design
and its use. The other advantage of the event-delegation model is that it performs much better in applications where many events are
generated. This performance improvement is due to the fact that the event-delegation model does not have to repeatedly process
unhandled events, as is the case of the event-inheritance 
model.

70. Which containers may have a MenuBar?


Frame
71. How are commas used in the initialization and iteration parts of a for statement?
Commas are used to separate multiple statements within the initialization and iteration parts of a for statement.

72. What is the purpose of the wait(), notify(), and notifyAll() methods?
The wait(),notify(), and notifyAll() methods are used to provide an efficient way for threads to wait for a shared resource. When a thread
executes an object's wait() method, it enters the waiting state. It only enters the ready state after another thread invokes the object's
notify() or notifyAll() methods.

73. What is an abstract method?


An abstract method is a method whose implementation is deferred to a subclass.

74. How are Java source code files named?


A Java source code file takes the name of a public class or interface that is defined within the file. A source code file may contain at most
one public class or interface. If a public class or interface is defined within a source code file, then the source code file must take the name
of the public class or interface. If no public class or interface is defined within a source code file, then the file must take on a name that is
different than its classes and interfaces. Source code files use the .java extension.

75. What is the relationship between the Canvas class and the Graphics class?
A Canvas object provides access to a Graphics object via its paint() method.

76. What are the high-level thread states?


The high-level thread states are ready, running, waiting, and dead.

77. What value does read() return when it has reached the end of a file?
The read() method returns -1 when it has reached the end of a file.
78. Can a Byte object be cast to a double value?
No, an object cannot be cast to a primitive value.

79. What is the difference between a static and a non-static inner class?
A non-static inner class may have object instances that are associated with instances of the class's outer class. A static inner class does not
have any object instances.

80. What is the difference between the String and StringBuffer classes?
String objects are constants. StringBuffer objects are not.

81. If a variable is declared as private, where may the variable be accessed?


A private variable may only be accessed within the class in which it is declared.

82. What is an object's lock and which objects have locks?


An object's lock is a mechanism that is used by multiple threads to obtain synchronized access to the object. A thread may execute a
synchronized method of an object only after it has acquired the object's lock. All objects and classes have locks. A class's lock is acquired on
the class's Class object.

83. What is the Dictionary class?


The Dictionary class provides the capability to store key-value pairs.

84. How are the elements of a BorderLayout organized?


The elements of a BorderLayout are organized at the borders (North, South, East, and West) and the center of a container.
85. What is the % operator?
It is referred to as the modulo or remainder operator. It returns the remainder of dividing the first operand by the second operand.
86. When can an object reference be cast to an interface reference?
An object reference be cast to an interface reference when the object implements the referenced interface.

87. What is the difference between a Window and a Frame?


The Frame class extends Window to define a main application window that can have a menu bar.

88. Which class is extended by all other classes?


The Object class is extended by all other classes.

89. Can an object be garbage collected while it is still reachable?


A reachable object cannot be garbage collected. Only unreachable objects may be garbage collected..

90. Is the ternary operator written x : y ? z or x ? y : z ?


It is written x ? y : z.

91. What is the difference between the Font and FontMetrics classes?
The FontMetrics class is used to define implementation-specific properties, such as ascent and descent, of a Font object.
92. How is rounding performed under integer division?
The fractional part of the result is truncated. This is known as rounding toward zero.

93. What happens when a thread cannot acquire a lock on an object?


If a thread attempts to execute a synchronized method or synchronized statement and is unable to acquire an object's lock, it enters the
waiting state until the lock becomes available.

94. What is the difference between the Reader/Writer class hierarchy and the InputStream/OutputStream class hierarchy?
The Reader/Writer class hierarchy is character-oriented, and the InputStream/OutputStream class hierarchy is byte-oriented.

95. What classes of exceptions may be caught by a catch clause?


A catch clause can catch any exception that may be assigned to the Throwable type. This includes the Error and Exception types.

96. If a class is declared without any access modifiers, where may the class be accessed?
A class that is declared without any access modifiers is said to have package access. This means that the class can only be accessed by other
classes and interfaces that are defined within the same package.

97. What is the SimpleTimeZone class?


The SimpleTimeZone class provides support for a Gregorian calendar.

98. What is the Map interface?


The Map interface replaces the JDK 1.1 Dictionary class and is used associate keys with values.99. Does a class inherit the constructors of its
superclass?
A class does not inherit constructors from any of its super classes.

100. For which statements does it make sense to use a label?


The only statements for which it makes sense to use a label are those statements that can enclose a break or continue statement.

101. What is the purpose of the System class?


The purpose of the System class is to provide access to system resources.

102. Which TextComponent method is used to set a TextComponent to the read-only state?
setEditable()

103. How are the elements of a CardLayout organized?


The elements of a CardLayout are stacked, one on top of the other, like a deck of cards.

104. Is &&= a valid Java operator?


No, it is not.

105. Name the eight primitive Java types.


The eight primitive types are byte, char, short, int, long, float, double, and boolean.
106. Which class should you use to obtain design information about an object?
The Class class is used to obtain information about an object's design.

107. What is the relationship between clipping and repainting?


When a window is repainted by the AWT painting thread, it sets the clipping regions to the area of the window that requires repainting.

108. Is "abc" a primitive value?


The String literal "abc" is not a primitive value. It is a String object.

109. What is the relationship between an event-listener interface and an event-adapter class?
An event-listener interface defines the methods that must be implemented by an event handler for a particular kind of event. An event
adapter provides a default implementation of an event-listener interface.

110. What restrictions are placed on the values of each case of a switch statement?
During compilation, the values of each case of a switch statement must evaluate to a value that can be promoted to an int value.

111. What modifiers may be used with an interface declaration?


An interface may be declared as public or abstract.

112. Is a class a subclass of itself?


A class is a subclass of itself.
113. What is the highest-level event class of the event-delegation model?
The java.util.EventObject class is the highest-level class in the event-delegation class hierarchy.

114. What event results from the clicking of a button?


The ActionEvent event is generated as the result of the clicking of a button.

115. How can a GUI component handle its own events?


A component can handle its own events by implementing the required event-listener interface and adding itself as its own event listener.

116. What is the difference between a while statement and a do statement?


A while statement checks at the beginning of a loop to see whether the next loop iteration should occur. A do statement checks at the end
of a loop to see whether the next iteration of a loop should occur. The do statement will always execute the body of a loop at least once.

117. How are the elements of a GridBagLayout organized?


The elements of a GridBagLayout are organized according to a grid. However, the elements are of different sizes and may occupy more
than one row or column of the grid. In addition, the rows and columns may have different sizes.

118. What advantage do Java's layout managers provide over traditional windowing systems?
Java uses layout managers to lay out components in a consistent manner across all windowing platforms. Since Java's layout managers
aren't tied to absolute sizing and positioning, they are able to accommodate platform-specific differences among windowing systems.

119. What is the Collection interface?


The Collection interface provides support for the implementation of a mathematical bag - an unordered collection of objects that may
contain duplicates.
120. What modifiers can be used with a local inner class?
A local inner class may be final or abstract.

121. What is the difference between static and non-static variables?


A static variable is associated with the class as a whole rather than with specific instances of a class. Non-static variables take on unique
values with each object instance.
122. What is the difference between the paint() and repaint() methods?
The paint() method supports painting via a Graphics object. The repaint() method is used to cause paint() to be invoked by the AWT
painting thread.

123. What is the purpose of the File class?


The File class is used to create objects that provide access to the files and directories of a local file system.

124. Can an exception be rethrown?


Yes, an exception can be rethrown.

125. Which Math method is used to calculate the absolute value of a number?
The abs() method is used to calculate absolute values.

126. How does multithreading take place on a computer with a single CPU?
The operating system's task scheduler allocates execution time to multiple tasks. By quickly switching between executing tasks, it creates
the impression that tasks execute sequentially.
127. When does the compiler supply a default constructor for a class?
The compiler supplies a default constructor for a class if no other constructors are provided.

128. When is the finally clause of a try-catch-finally statement executed?


The finally clause of the try-catch-finally statement is always executed unless the thread of execution terminates or an exception occurs
within the execution of the finally clause.

129. Which class is the immediate superclass of the Container class?


Component

130. If a method is declared as protected, where may the method be accessed?


A protected method may only be accessed by classes or interfaces of the same package or by subclasses of the class in which it is declared.

131. How can the Checkbox class be used to create a radio button?
By associating Checkbox objects with a CheckboxGroup.

132. Which non-Unicode letter characters may be used as the first character of an identifier?
The non-Unicode letter characters $ and _ may appear as the first character of an identifier

133. What restrictions are placed on method overloading?


Two methods may not have the same name and argument list but different return types.
134. What happens when you invoke a thread's interrupt method while it is sleeping or waiting?
When a task's interrupt() method is executed, the task enters the ready state. The next time the task enters the running state, an
InterruptedException is thrown.

135. What is casting?


There are two types of casting, casting between primitive numeric types and casting between object references. Casting between numeric
types is used to convert larger values, such as double values, to smaller values, such as byte values. Casting between object references is
used to refer to an object by a compatible class, interface, or array type reference.

136. What is the return type of a program's main() method?


A program's main() method has a void return type.

137. Name four Container classes.


Window, Frame, Dialog, FileDialog, Panel, Applet, or ScrollPane

138. What is the difference between a Choice and a List?


A Choice is displayed in a compact form that requires you to pull it down to see the list of available choices. Only one item may be selected
from a Choice. A List may be displayed in such a way that several List items are visible. A List supports the selection of one or more List
items.
139. What class of exceptions are generated by the Java run-time system?
The Java runtime system generates RuntimeException and Error exceptions.

140. What class allows you to read objects directly from a stream?
The ObjectInputStream class supports the reading of objects from input streams.
141. What is the difference between a field variable and a local variable?
A field variable is a variable that is declared as a member of a class. A local variable is a variable that is declared local to a method.

142. Under what conditions is an object's finalize() method invoked by the garbage collector?
The garbage collector invokes an object's finalize() method when it detects that the object has become unreachable.

143. How are this () and super () used with constructors?


this() is used to invoke a constructor of the same class. super() is used to invoke a superclass constructor.

144. What is the relationship between a method's throws clause and the exceptions that can be thrown during the method's execution?
A method's throws clause must declare any checked exceptions that are not caught within the body of the method.

145. What is the difference between the JDK 1.02 event model and the event-delegation model introduced with JDK 1.1?
The JDK 1.02 event model uses an event inheritance or bubbling approach. In this model, components are required to handle their own
events. If they do not handle a particular event, the event is inherited by (or bubbled up to) the component's container. The container then
either handles the event or it is bubbled up to its container and so on, until the highest-level container has been tried.
In the event-delegation model, specific objects are designated as event handlers for GUI components. These objects implement event-
listener interfaces. The event-delegation model is more efficient than the event-inheritance model because it eliminates the processing
required to support the bubbling of unhandled events.

146. How is it possible for two String objects with identical values not to be equal under the == operator?
The == operator compares two objects to determine if they are the same object in memory. It is possible for two String objects to have the
same value, but located indifferent areas of memory.

147. Why are the methods of the Math class static?


So they can be invoked as if they are a mathematical code library.
148. What Checkbox method allows you to tell if a Checkbox is checked?
getState()

149. What state is a thread in when it is executing?


An executing thread is in the running state.

150. What are the legal operands of the instanceof operator?


The left operand is an object reference or null value and the right operand is a class, interface, or array type.

151. How are the elements of a GridLayout organized?


The elements of a GridBad layout are of equal size and are laid out using the squares of a grid.

152. What an I/O filter?


An I/O filter is an object that reads from one stream and writes to another, usually altering the data in some way as it is passed from one
stream to another.

153. If an object is garbage collected, can it become reachable again?


Once an object is garbage collected, it ceases to exist. It can no longer become reachable again.

154. What is the Set interface?


The Set interface provides methods for accessing the elements of a finite mathematical set. Sets do not allow duplicate elements. 
155. What classes of exceptions may be thrown by a throw statement?
A throw statement may throw any expression that may be assigned to the Throwable type.
156. What are E and PI?
E is the base of the natural logarithm and PI is mathematical value pi.

157. Are true and false keywords?


The values true and false are not keywords.

158. What is a void return type?


A void return type indicates that a method does not return a value.

159. What is the purpose of the enableEvents() method?


The enableEvents() method is used to enable an event for a particular object. Normally, an event is enabled when a listener is added to an
object for a particular event. The enableEvents() method is used by objects that handle events by overriding their event-dispatch methods.

160. What is the difference between the File and RandomAccessFile classes?
The File class encapsulates the files and directories of the local file system. The RandomAccessFile class provides the methods needed to
directly access data contained in any part of a file.

161. What happens when you add a double value to a String?


The result is a String object.162. What is your platform's default character encoding?
If you are running Java on English Windows platforms, it is probably Cp1252. If you are running Java on English Solaris platforms, it is most
likely 8859_1..

163. Which package is always imported by default?


The java.lang package is always imported by default.

164. What interface must an object implement before it can be written to a stream as an object?
An object must implement the Serializable or Externalizable interface before it can be written to a stream as an object.

165. How are this and super used?


this is used to refer to the current object instance. super is used to refer to the variables and methods of the superclass of the current
object instance.

166. What is the purpose of garbage collection?


The purpose of garbage collection is to identify and discard objects that are no longer needed by a program so that their resources may be
reclaimed and 
reused.

167. What is a compilation unit?


A compilation unit is a Java source code file.

168. What interface is extended by AWT event listeners?


All AWT event listeners extend the java.util.EventListener interface.
169. What restrictions are placed on method overriding?
Overridden methods must have the same name, argument list, and return type. 
The overriding method may not limit the access of the method it overrides. 
The overriding method may not throw any exceptions that may not be thrown 
by the overridden method.

170. How can a dead thread be restarted?


A dead thread cannot be restarted.

171. What happens if an exception is not caught?


An uncaught exception results in the uncaughtException() method of the thread's ThreadGroup being invoked, which eventually results in
the termination of the program in which it is thrown.

172. What is a layout manager?


A layout manager is an object that is used to organize components in a container.

173. Which arithmetic operations can result in the throwing of an ArithmeticException?


Integer / and % can result in the throwing of an ArithmeticException.

174. What are three ways in which a thread can enter the waiting state?
A thread can enter the waiting state by invoking its sleep() method, by blocking on I/O, by unsuccessfully attempting to acquire an object's
lock, or by invoking an object's wait() method. It can also enter the waiting state by invoking its 
(deprecated) suspend() method.

175. Can an abstract class be final?


An abstract class may not be declared as final.176. What is the ResourceBundle class?
The ResourceBundle class is used to store locale-specific resources that can be loaded by a program to tailor the program's appearance to
the particular locale in which it is being run.

177. What happens if a try-catch-finally statement does not have a catch clause to handle an exception that is thrown within the body of
the try statement?
The exception propagates up to the next higher level try-catch statement (if any) or results in the program's termination.

178. What is numeric promotion?


Numeric promotion is the conversion of a smaller numeric type to a larger numeric type, so that integer and floating-point operations may
take place. In numerical promotion, byte, char, and short values are converted to int 
values. The int values are also converted to long values, if necessary. The long and float values are converted to double values, as required.

179. What is the difference between a Scrollbar and a ScrollPane?


A Scrollbar is a Component, but not a Container. A ScrollPane is a Container. A ScrollPane handles its own events and performs its own
scrolling.

180. What is the difference between a public and a non-public class?


A public class may be accessed outside of its package. A non-public class may not be accessed outside of its package.

181. To what value is a variable of the boolean type automatically initialized?


The default value of the boolean type is false.

182. Can try statements be nested?


Try statements may be tested.
183. What is the difference between the prefix and postfix forms of the ++ operator?
The prefix form performs the increment operation and returns the value of the increment operation. The postfix form returns the current
value all of the expression and then performs the increment operation on that value.

184. What is the purpose of a statement block?


A statement block is used to organize a sequence of statements as a single statement group.

185. What is a Java package and how is it used?


A Java package is a naming context for classes and interfaces. A package is used to create a separate name space for groups of classes and
interfaces. Packages are also used to organize related classes and interfaces into a single API unit and to control accessibility to these
classes and interfaces.

186. What modifiers may be used with a top-level class?


A top-level class may be public, abstract, or final.

187. What are the Object and Class classes used for?
The Object class is the highest-level class in the Java class hierarchy. The Class class is used to represent the classes and interfaces that are
loaded by a Java program.

188. How does a try statement determine which catch clause should be used to handle an exception?
When an exception is thrown within the body of a try statement, the catch clauses of the try statement are examined in the order in which
they appear. The first catch clause that is capable of handling the exception is executed. 
The remaining catch clauses are ignored.

189. Can an unreachable object become reachable again?


An unreachable object may become reachable again. This can happen when the object's finalize() method is invoked and the object
performs an operation which causes it to become accessible to reachable objects.190. When is an object subject to garbage collection?
An object is subject to garbage collection when it becomes unreachable to the program in which it is used.

191. What method must be implemented by all threads?


All tasks must implement the run() method, whether they are a subclass of Thread or implement the Runnable interface.

192. What methods are used to get and set the text label displayed by a Button object?
getLabel() and setLabel()

193. Which Component subclass is used for drawing and painting?


Canvas

194. What are synchronized methods and synchronized statements?


Synchronized methods are methods that are used to control access to an object. A thread only executes a synchronized method after it has
acquired the lock for the method's object or class. Synchronized statements are similar to synchronized methods. A synchronized
statement can only be executed after a thread has acquired the lock for the object or class referenced in the synchronized statement195.
What are the two basic ways in which classes that can be run as threads may be defined?
A thread class may be declared as a subclass of Thread, or it may implement the Runnable interface.

196. What are the problems faced by Java programmers who don't use layout managers?
Without layout managers, Java programmers are faced with determining how their GUI will be displayed across multiple windowing
systems and finding a common sizing and positioning that will work within the constraints imposed by each windowing system.

197. What is the difference between an if statement and a switch statement?


The if statement is used to select among two alternatives. It uses a boolean expression to decide which alternative should be executed. The
switch statement is used to select among multiple alternatives. It uses an int expression to determine which alternative should be
executed.

C++

What is encapsulation??
Containing and hiding information about an object, such as internal data structures and 
code. Encapsulation isolates the internal complexity of an object's operation from the rest 
of the application. For example, a client component asking for net revenue from a business 
object need not know the data's origin.

What is inheritance?
Inheritance allows one class to reuse the state and behavior of another class. The derived 
class inherits the properties and method implementations of the base class and extends it by 
overriding methods and adding additional properties and methods.
What is Polymorphism??

Polymorphism allows a client to treat different objects in the same way even if they were 
created from different classes and exhibit different behaviors. You can use implementation 
inheritance to achieve polymorphism in languages such as C++ and Java. Base class object's 
pointer can invoke methods in derived class objects. You can also achieve polymorphism in 
C++ by function overloading and operator overloading.

What is constructor or ctor?

Constructor creates an object and initializes it. It also creates vtable for virtual 
functions. It is different from other methods in a class.

What is destructor?
Destructor usually deletes any extra resources allocated by the object. 
What is default constructor?
Constructor with no arguments or all the arguments has default values.

What is copy constructor?


Constructor which initializes the it's object member variables ( by shallow copying) with 
another object of the same class. If you don't implement one in your class then compiler 
implements one for you. 
for example:
Boo Obj1(10); // calling Boo constructor
Boo Obj2(Obj1); // calling boo copy constructor
Boo Obj2 = Obj1;// calling boo copy constructor

When are copy constructors called? 


Copy constructors are called in following cases: 
a) when a function returns an object of that class by value
b) when the object of that class is passed by value as an argument to a function
c) when you construct an object based on another object of the same class
d) When compiler generates a temporary object

What is assignment operator? 


Default assignment operator handles assigning one object to another of the same class. 
Member to member copy (shallow copy)

What are all the implicit member functions of the class? Or what are all the functions which 
compiler implements for us if we don't define one.??
default ctor
copy ctor
assignment operator
default destructor
address operator

What is conversion constructor?


constructor with a single argument makes that constructor as conversion ctor and it can be 
used for type conversion.
for example:
class Boo
{
public:
Boo( int i );
};
Boo BooObject = 10 ; // assigning int 10 Boo object

What is conversion operator??


class can have a public method for specific data type conversions.
for example:
class Boo
{
double value;
public:
Boo(int i )
operator double() 

return value;
}
};
Boo BooObject;
double i = BooObject; // assigning object to variable i of type double. now conversion 
operator gets called to assign the value.

What is diff between malloc()/free() and new/delete?


malloc allocates memory for object in heap but doesn't invoke object's constructor to 
initiallize the object.
new allocates memory and also invokes constructor to initialize the object.
malloc() and free() do not support object semantics 
Does not construct and destruct objects 
string * ptr = (string *)(malloc (sizeof(string)))
Are not safe 
Does not calculate the size of the objects that it construct 
Returns a pointer to void 
int *p = (int *) (malloc(sizeof(int)));
int *p = new int;
Are not extensible 
new and delete can be overloaded in a class 
"delete" first calls the object's termination routine (i.e. its destructor) and then 
releases the space the object occupied on the heap memory. If an array of objects was 
created using new, then delete must be told that it is dealing with an array by preceding 
the name with an empty []:- 
Int_t *my_ints = new Int_t[10];
...
delete []my_ints;
What is the diff between "new" and "operator new" ? 

"operator new" works like malloc.


What is difference between template and macro??
There is no way for the compiler to verify that the macro parameters are of compatible 
types. The macro is expanded without any special type checking.
If macro parameter has a postincremented variable ( like c++ ), the increment is performed 
two times.
Because macros are expanded by the preprocessor, compiler error messages will refer to the 
expanded macro, rather than the macro definition itself. Also, the macro will show up in 
expanded form during debugging. 
for example:
Macro:
#define min(i, j) (i < j ? i : j)
template:
template 
T min (T i, T j) 

return i < j ? i : j;
}
What are C++ storage classes?
auto
register
static
extern
auto: the default. Variables are automatically created and initialized when they are defined 
and are destroyed at the end of the block containing their definition. They are not visible 
outside that block
register: a type of auto variable. a suggestion to the compiler to use a CPU register for 
performance
static: a variable that is known only in the function that contains its definition but is 
never destroyed and retains its value between calls to that function. It exists from the 
time the program begins execution
extern: a static variable whose definition and placement is determined when all object and 
library modules are combined (linked) to form the executable code file. It can be visible 
outside the file where it is defined.
What are storage qualifiers in C++ ?
They are..
const
volatile
mutable
Const keyword indicates that memory once initialized, should not be altered by a program.
volatile keyword indicates that the value in the memory location can be altered even though 
nothing in the program
code modifies the contents. for example if you have a pointer to hardware location that 
contains the time, where hardware changes the value of this pointer variable and not the 
program. The intent of this keyword to improve the optimization ability of the compiler. 
mutable keyword indicates that particular member of a structure or class can be altered even 
if a particular structure variable, class, or class member function is constant.
struct data
{
char name[80];
mutable double salary;
}
const data MyStruct = { "Satish Shetty", 1000 }; //initlized by complier
strcpy ( MyStruct.name, "Shilpa Shetty"); // compiler error
MyStruct.salaray = 2000 ; // complier is happy allowed
What is reference ??
reference is a name that acts as an alias, or alternative name, for a previously defined 
variable or an object. prepending variable with "&" symbol makes it as reference. for 
example: 
int a;
int &b = a; 
What is passing by reference?
Method of passing arguments to a function which takes parameter of type reference. for 
example:
void swap( int & x, int & y )
{
int temp = x;
x = y;
y = x; 
}
int a=2, b=3;
swap( a, b );
Basically, inside the function there won't be any copy of the arguments "x" and "y" instead 
they refer to original variables a and b. so no extra memory needed to pass arguments and it 
is more efficient. 
When do use "const" reference arguments in function?
a) Using const protects you against programming errors that inadvertently alter data.
b) Using const allows function to process both const and non-const actual arguments, while a 
function without const in the prototype can only accept non constant arguments.
c) Using a const reference allows the function to generate and use a temporary variable 
appropriately.
When are temporary variables created by C++ compiler?
Provided that function parameter is a "const reference", compiler generates temporary 
variable in following 2 ways. 
a) The actual argument is the correct type, but it isn't Lvalue
double Cuberoot ( const double & num )
{
num = num * num * num;
return num;
}
double temp = 2.0;
double value = cuberoot ( 3.0 + temp ); // argument is a expression and not a Lvalue;
b) The actual argument is of the wrong type, but of a type that can be converted to the 
correct type
long temp = 3L;
double value = cuberoot ( temp); // long to double conversion 
What is virtual function?
When derived class overrides the base class method by redefining the same function, then if 
client wants to access redefined the method from derived class through a pointer from base 
class object, then you must define this function in base class as virtual function.
class parent
{
void Show() 

cout << "i'm parent" << endl;
}
};
class child: public parent
{
void Show() 

cout << "i'm child" << endl;
}
};
parent * parent_object_ptr = new child;
parent_object_ptr->show() // calls parent->show() i 
now we goto virtual world...
class parent
{
virtual void Show() 

cout << "i'm parent" << endl;
}
};
class child: public parent
{
void Show() 

cout << "i'm child" << endl;
}
};
parent * parent_object_ptr = new child;
parent_object_ptr->show() // calls child->show() 
What is pure virtual function? or what is abstract class?
When you define only function prototype in a base class without and do the complete 
implementation in derived class. This base class is called abstract class and client won't 
able to instantiate an object using this base class.
You can make a pure virtual function or abstract class this way.. 
class Boo
{
void foo() = 0;
}
Boo MyBoo; // compilation error
What is Memory alignment??
The term alignment primarily means the tendency of an address pointer value to be a multiple 
of some power of two. So a pointer with two byte alignment has a zero in the least 
significant bit. And a pointer with four byte alignment has a zero in both the two least 
significant bits. And so on. More alignment means a longer sequence of zero bits in the 
lowest bits of a pointer.
What problem does the namespace feature solve? 
Multiple providers of libraries might use common global identifiers causing a name collision 
when an application tries to link with two or more such libraries. The namespace feature 
surrounds a library's external declarations with a unique namespace that eliminates the 
potential for those collisions. 
namespace [identifier] { namespace-body }
A namespace declaration identifies and assigns a name to a declarative region.
The identifier in a namespace declaration must be unique in the declarative region in which 
it is used. The identifier is the name of the namespace and is used to reference its 
members.
What is the use of 'using' declaration?
A using declaration makes it possible to use a name from a namespace without the scope 
operator. 
What is an Iterator class? 
A class that is used to traverse through the objects maintained by a container class. There 
are five categories of iterators: input iterators, output iterators, forward iterators, 
bidirectional iterators, random access. An iterator is an entity that gives access to the 
contents of a container object without violating encapsulation constraints. Access to the 
contents is granted on a one-at-a-time basis in order. The order can be storage order (as in 
lists and queues) or some arbitrary order (as in array indices) or according to some 
ordering relation (as in an ordered binary tree). The iterator is a construct, which 
provides an interface that, when called, yields either the next element in the container, or 
some value denoting the fact that there are no more elements to examine. Iterators hide the 
details of access to and update of the elements of a container class. Something like a 
pointer. 
What is a dangling pointer? 
A dangling pointer arises when you use the address of an object after its lifetime is over. 
This may occur in situations like returning addresses of the automatic variables from a 
function or using the address of the memory block after it is freed.
What do you mean by Stack unwinding? 
It is a process during exception handling when the destructor is called for all local 
objects in the stack between the place where the exception was thrown and where it is 
caught.
Name the operators that cannot be overloaded??
sizeof, ., .*, .->, ::, ?: 
What is a container class? What are the types of container classes? 
A container class is a class that is used to hold objects in memory or external storage. A 
container class acts as a generic holder. A container class has a predefined behavior and a 
well-known interface. A container class is a supporting class whose purpose is to hide the 
topology used for maintaining the list of objects in memory. When a container class contains 
a group of mixed objects, the container is called a heterogeneous container; when the 
container is holding a group of objects that are all the same, the container is called a 
homogeneous container. 
What is inline function??
The __inline keyword tells the compiler to substitute the code within the function 
definition for every instance of a function call. However, substitution occurs only at the 
compiler's discretion. For example, the compiler does not inline a function if its address 
is taken or if it is too large to inline.
What is overloading??
With the C++ language, you can overload functions and operators. Overloading is the practice 
of supplying more than one definition for a given function name in the same scope.
- Any two functions in a set of overloaded functions must have different argument lists.
- Overloading functions with argument lists of the same types, based on return type alone, 
is an error. 
What is Overriding?
To override a method, a subclass of the class that originally declared the method must 
declare a method with the same name, return type (or a subclass of that return type), and 
same parameter list.
The definition of the method overriding is: 
• Must have same method name. 
• Must have same data type. 
• Must have same argument list. 
Overriding a method means that replacing a method functionality in child class. To imply 
overriding functionality we need parent and child classes. In the child class you define the 
same method signature as one defined in the parent class.
What is "this" pointer?
The this pointer is a pointer accessible only within the member functions of a class, 
struct, or union type. It points to the object for which the member function is called. 
Static member functions do not have a this pointer.
When a nonstatic member function is called for an object, the address of the object is 
passed as a hidden argument to the function. For example, the following function call
myDate.setMonth( 3 );
can be interpreted this way:
setMonth( &myDate, 3 );
The object's address is available from within the member function as the this pointer. It is 
legal, though unnecessary, to use the this pointer when referring to members of the class.
What happens when you make call "delete this;" ??
The code has two built-in pitfalls. First, if it executes in a member function for an 
extern, static, or automatic object, the program will probably crash as soon as the delete 
statement executes. There is no portable way for an object to tell that it was instantiated 
on the heap, so the class cannot assert that its object is properly instantiated. Second, 
when an object commits suicide this way, the using program might not know about its demise. 
As far as the instantiating program is concerned, the object remains in scope and continues 
to exist even though the object did itself in. Subsequent dereferencing of the pointer can 
and usually does lead to disaster.
You should never do this. Since compiler does not know whether the object was allocated on 
the stack or on the heap, "delete this" could cause a disaster.
How virtual functions are implemented C++?
Virtual functions are implemented using a table of function pointers, called the vtable. 
There is one entry in the table per virtual function in the class. This table is created by 
the constructor of the class. When a derived class is constructed, its base class is 
constructed first which creates the vtable. If the derived class overrides any of the base 
classes virtual functions, those entries in the vtable are overwritten by the derived class 
constructor. This is why you should never call virtual functions from a constructor: because 
the vtable entries for the object may not have been set up by the derived class constructor 
yet, so you might end up calling base class implementations of those virtual functions
What is name mangling in C++??
The process of encoding the parameter types with the function/method name into a unique name 
is called name mangling. The inverse process is called demangling.
For example Foo::bar(int, long) const is mangled as `bar__C3Fooil'. 
For a constructor, the method name is left out. That is Foo::Foo(int, long) const is mangled 
as `__C3Fooil'.
What is the difference between a pointer and a reference? 
A reference must always refer to some object and, therefore, must always be initialized; 
pointers do not have such restrictions. A pointer can be reassigned to point to different 
objects while a reference always refers to an object with which it was initialized.
How are prefix and postfix versions of operator++() differentiated? 
The postfix version of operator++() has a dummy parameter of type int. The prefix version 
does not have dummy parameter.
What is the difference between const char *myPointer and char *const myPointer? 
Const char *myPointer is a non constant pointer to constant data; while char *const 
myPointer is a constant pointer to non constant data. 
How can I handle a constructor that fails?
throw an exception. Constructors don't have a return type, so it's not possible to use 
return codes. The best way to signal constructor failure is therefore to throw an exception. 
How can I handle a destructor that fails?
Write a message to a log-file. But do not throw an exception. 
The C++ rule is that you must never throw an exception from a destructor that is being 
called during the "stack unwinding" process of another exception. For example, if someone 
says throw Foo(), the stack will be unwound so all the stack frames between the throw Foo() 
and the } catch (Foo e) { will get popped. This is called stack unwinding. 
During stack unwinding, all the local objects in all those stack frames are destructed. If 
one of those destructors throws an exception (say it throws a Bar object), the C++ runtime 
system is in a no-win situation: should it ignore the Bar and end up in the } catch (Foo e) 
{ where it was originally headed? Should it ignore the Foo and look for a } catch (Bar e) { 
handler? There is no good answer -- either choice loses information. 
So the C++ language guarantees that it will call terminate() at this point, and terminate() 
kills the process. Bang you're dead. 
What is Virtual Destructor?
Using virtual destructors, you can destroy objects without knowing their type - the correct 
destructor for the object is invoked using the virtual function mechanism. Note that 
destructors can also be declared as pure virtual functions for abstract classes. 
if someone will derive from your class, and if someone will say "new Derived", where 
"Derived" is derived from your class, and if someone will say delete p, where the actual 
object's type is "Derived" but the pointer p's type is your class.
Can you think of a situation where your program would crash without reaching the breakpoint 
which you set at the beginning of main()?
C++ allows for dynamic initialization of global variables before main() is invoked. It is 
possible that initialization of global will invoke some function. If this function crashes 
the crash will occur before main() is entered. 
Name two cases where you MUST use initialization list as opposed to assignment in 
constructors.
Both non-static const data members and reference data members cannot be assigned values; 
instead, you should use initialization list to initialize them. 
Can you overload a function based only on whether a parameter is a value or a reference?
No. Passing by value and by reference looks identical to the caller. 
What are the differences between a C++ struct and C++ class?
The default member and base class access specifiers are different. 
The C++ struct has all the features of the class. The only differences are that a struct 
defaults to public member access and public base class inheritance, and a class defaults to 
the private access specifier and private base class inheritance. 
What does extern "C" int func(int *, Foo) accomplish?
It will turn off "name mangling" for func so that one can link to code compiled by a C 
compiler. 
How do you access the static member of a class?
::
What is multiple inheritance(virtual inheritance)? What are its advantages and 
disadvantages?
Multiple Inheritance is the process whereby a child can be derived from more than one parent 
class. The advantage of multiple inheritance is that it allows a class to inherit the 
functionality of more than one base class thus allowing for modeling of complex 
relationships. The disadvantage of multiple inheritance is that it can lead to a lot of 
confusion(ambiguity) when two base classes implement a method with the same name. 
What are the access privileges in C++? What is the default access level?
The access privileges in C++ are private, public and protected. The default access level 
assigned to members of a class is private. Private members of a class are accessible only 
within the class and by friends of the class. Protected members are accessible by the class 
itself and it's sub-classes. Public members of a class can be accessed by anyone.
What is a nested class? Why can it be useful?
A nested class is a class enclosed within the scope of another class. For example:
// Example 1: Nested class
//
class OuterClass
{
class NestedClass
{
// ...
};
// ...
};
Nested classes are useful for organizing code and controlling access and dependencies. 
Nested classes obey access rules just like other parts of a class do; so, in Example 1, if 
NestedClass is public then any code can name it as OuterClass::NestedClass. Often nested 
classes contain private implementation details, and are therefore made private; in Example 
1, if NestedClass is private, then only OuterClass's members and friends can use 
NestedClass.
When you instantiate as outer class, it won't instantiate inside class.
What is a local class? Why can it be useful?
local class is a class defined within the scope of a function -- any function, whether a 
member function or a free function. For example:
// Example 2: Local class
//
int f()
{
class LocalClass
{
// ...
};
// ...
};
Like nested classes, local classes can be a useful tool for managing code dependencies. 
Can a copy constructor accept an object of the same class as parameter, instead of reference 
of the object?
No. It is specified in the definition of the copy constructor itself. It should generate an 
error if a programmer specifies a copy constructor with a first argument that is an object 
and not a reference.
(From Microsoft) Assume I have a linked list contains all of the alphabets from ‘A’ to ‘Z’. 
I want to find the letter ‘Q’ in the list, how does you perform the search to find the ‘Q’?
How do you write a function that can reverse a linked-list? (Cisco System)
void reverselist(void)
{
if(head==0)
return;
if(head->next==0)
return;
if(head->next==tail)
{
head->next = 0;
tail->next = head;
}
else
{
node* pre = head;
node* cur = head->next;
node* curnext = cur->next;
head->next = 0;
cur->next = head;
for(; curnext!=0; )
{
cur->next = pre;
pre = cur;
cur = curnext;
curnext = curnext->next;
}
curnext->next = cur;
}
}
How do you find out if a linked-list has an end? (i.e. the list is not a cycle)
You can find out by using 2 pointers. One of them goes 2 nodes each time. The second one 
goes at 1 nodes each time. If there is a cycle, the one that goes 2 nodes each time will 
eventually meet the one that goes slower. If that is the case, then you will know the 
linked-list is a cycle.
How can you tell what shell you are running on UNIX system?
You can do the Echo $RANDOM. It will return a undefined variable if you are from the 
C-Shell, just a return prompt if you are from the Bourne shell, and a 5 digit random numbers 
if you are from the Korn shell. You could also do a ps -l and look for the shell with the 
highest PID.
What is Boyce Codd Normal form? 
A relation schema R is in BCNF with respect to a set F of functional dependencies if for all 
functional dependencies in F+ of the form a->b, where a and b is a subset of R, at least one 
of the following holds: 
• a->b is a trivial functional dependency (b is a subset of a) 
• a is a superkey for schema R 
Could you tell something about the Unix System Kernel?
The kernel is the heart of the UNIX openrating system, it’s reponsible for controlling the 
computer’s resouces and scheduling user jobs so that each one gets its fair share of 
resources. 
What is a Make file?
Make file is a utility in Unix to help compile large programs. It helps by only compiling 
the portion of the program that has been changed
How do you link a C++ program to C functions? 
By using the extern "C" linkage specification around the C function declarations. 
Explain the scope resolution operator. 
Design and implement a String class that satisfies the following:
Supports embedded nulls 
Provide the following methods (at least) 
Constructor 
Destructor 
Copy constructor 
Assignment operator 
Addition operator (concatenation) 
Return character at location 
Return substring at location 
Find substring 
Provide versions of methods for String and for char* arguments 
Suppose that data is an array of 1000 integers. Write a single function call that will sort 
the 100 elements data [222] through data [321].
Answer: quicksort ((data + 222), 100);
What is a modifier?
What is an accessor?

Differentiate between a template class and class template.

When does a name clash occur?

Define namespace.

What is the use of ‘using’ declaration.

What is an Iterator class?


List out some of the OODBMS available.

List out some of the object-oriented methodologies.

What is an incomplete type?

What is a dangling pointer?

Differentiate between the message and method.

What is an adaptor class or Wrapper class?

What is a Null object?

What is class invariant?


What do you mean by Stack unwinding?
Define precondition and post-condition to a member function.

What are the conditions that have to be met for a condition to be an invariant of the class?

What are proxy objects?

Name some pure object oriented languages.

Name the operators that cannot be overloaded. 

What is a node class?

What is an orthogonal base class?

What is a container class? What are the types of container classes?

What is a protocol class?

What is a mixin class?

What is a concrete class?

What is the handle class?

What is an action class?

When can you tell that a memory leak will occur?


What is a parameterized type?
Differentiate between a deep copy and a shallow copy?
What is an opaque pointer?
What is a smart pointer?
What is reflexive association?
What is slicing?
What is name mangling?
What are proxy objects?
What is cloning?
Describe the main characteristics of static functions.
Will the inline function be compiled as the inline function always? Justify.
Define a way other than using the keyword inline to make a function inline.
How can a '::' operator be used as unary operator?
What is placement new?
What do you mean by analysis and design?
What are the steps involved in designing?

What are the main underlying concepts of object orientation?

What do u meant by "SBI" of an object?

Differentiate persistent & non-persistent objects?


What do you meant by active and passive objects?

What is meant by software development method?

What do you meant by static and dynamic modeling?

How to represent the interaction between the modeling elements?

Why generalization is very strong?

Differentiate Aggregation and containment?


Can link and Association applied interchangeably?

What is meant by "method-wars"?

Whether unified method and unified modeling language are same or different?

Who were the three famous amigos and what was their contribution to the object community?

Differentiate the class representation of Booch, Rumbaugh and UML?

What is an USECASE? Why it is needed?

Who is an Actor?

What is guard condition?

Differentiate the following notations?

USECASE is an implementation independent notation. How will the designer give the 
implementation details of a particular USECASE to the programmer?

Suppose a class acts an Actor in the problem domain, how to represent it in the static 
model?

Why does the function arguments are called as "signatures"?


SQL
What is the full form of SQL ?

Structured Query Language (SQL). It is pronounced “sequel”.SQl is a language that provides an interface to relational
database systems. It was developed by IBM.
What are two methods of retrieving SQL?

What is a deadlock in SQL ?

Deadlock is a situation when two processes, each having a lock on one piece of data, attempt to acquire a lock on the
other’s piece. Each process  would wait indefinitely for the other to release the lock, unless one of the user processes is
terminated. SQLServer detects deadlocks and terminates one user’s process.

What is livelock in SQL ?

A livelock is one, where a  request for an exclusive lock is repeatedly denied because a series of overlapping shared locks
keeps interfering. SQL Server detects the situation after four denials and refuses further shared locks. A livelock also occurs
when read transactions monopolize a table or page, forcing a write transaction to wait indefinitely.

Some important system function to get the current user details


 USER_ID()
 USER_NAME()
 SESSION_USER
 CURRENT_USER
 USER
 SUSER_SID()
 HOST_NAME().
What’s the difference between a primary key and a unique key?

Both primary key and unique enforce uniqueness of the column on which they are defined. But by default primary key
creates a clustered index on the column, where are unique creates a nonclustered index by default. Another major
difference is that, primary key doesn’t allow NULLs, but unique key allows one NULL only.

What cursor type do you use to retrieve multiple recordsets?

What is candidate key, alternate key, composite key in SQL ?

A candidate key is one that can identify each row of a table  uniquely.Generally a candidate key becomes the primary key of
the table. If the table has more than one candidate key, one of them will become the primary key, and the rest are called
alternate keys.A key formed by combining at least two or more columns is called composite key.

Explain the architecture of SQL Server

What is the difference between a “where” clause and a “having” clause in SQL ?

“Where” Clause in SQL is a kind of restiriction statement. You use where clause to restrict all the data from DB.Where
clause is using before result retrieving. But Having clause is using after retrieving the data.Having clause is a kind of
filtering command from the selected data.

What is the basic form of a SQL statement to read data out of a table?

Basic form to read data out of table in SQL is “SELECT * FROM tablename”. Answer with “where” close wont be proper
because it is an additional thing with basic select statement.

What’s the maximum size of a row in SQL table?


8060 bytes.

What are the tradeoffs with having indexes?


 Faster selects
 slower updates
 Extra storage space to store indexes
 Updates are slower because in addition to updating the table you have to update the index.
What’s the difference between DELETE TABLE and TRUNCATE TABLE commands in SQL?

DELETE TABLE is a logged operation, so the deletion of each row gets logged in the transaction log, which makes it slow.
TRUNCATE TABLE also deletes all the rows in a table, but it won’t log the deletion of each row, instead it logs the de
allocation of the data pages of the table, which makes it faster. TRUNCATE TABLE can be rolled back

What is a “join” statement in SQL?


‘join’ used to connect two or more tables logically with or without common field.

What is “normalization”? “Denormalization”? Why do you sometimes want to denormalize?

Normalizing data means eliminating redundant information from a table and organizing the data so that future changes to
the table are easier. Denormalization means allowing redundancy in a table. The main benefit of denormalization is
improved performance with simplified data retrieval and manipulation. This is done by reduction in the number of joins
needed for data processing.
How to restart SQL Server?
from command line, using the SQLSERVR.EXE.
 -m is used for starting SQL Server in single user mode
 -f is used to start the SQL Server in minimal confuguration mode.
What is a “constraint” in SQL?

A constraint allows you to apply simple referential integrity checks to a table. There are four primary types of constraints
that are currently supported by SQL Server
 PRIMARY/UNIQUE - enforces uniqueness of a particular table column.
 DEFAULT - specifies a default value for a column in case an insert operation does not provide one.
 FOREIGN KEY - validates that every value in a column exists in a column of another table.
 CHECK - checks that every value stored in a column is in some specified list.
 NOT NULL is one more constraint which does not allow values in the specific column to be null. And also it the only
constraint which is not a table level constraint.
Each type of constraint performs a specific type of action. Default is not a constraint.

Different Types of joins in SQL


 INNER JOINs
 OUTER JOINs
 LEFT OUTER JOINS
 RIGHT OUTER JOINS
 FULL
 CROSS JOINs
What types of index data structures can you have?
An index helps to faster search values in tables. The three most commonly used index-types are:
 B-Tree: builds a tree of possible values with a list of row IDs that have the leaf value. Needs a lot of space and is
the default index type for most databases.
 Bitmap: string of bits for each possible value of the column. Each bit string has one bit for each row. Needs only few
space and is very fast.(however, domain of value cannot be large, e.g. SEX(m,f); degree(BS,MS,PHD)
 Hash: A hashing algorithm is used to assign a set of characters to represent a text string such as a composite of
keys or partial keys, and compresses the underlying data. Takes longer to build and is supported by relatively few
databases.
Types of cursors in SQL ?
 Static
 Dynamic
 Forward-only
 Keyset-driven
What is a “primary key”?

Primary Key is a type of a constraint enforcing uniqueness and data integrity for each row of a table. All columns
participating in a primary key constraint must possess the NOT NULL property.For example “user Id” should be unique for
users, so we can make that field a s primary key in some tables for making sure that value wont repeat.

What is a “trigger”?

Triggers are stored procedures created in order to enforce integrity rules in a database. A trigger is executed every time a
data-modification operation occurs (i.e., insert, update or delete). Triggers are executed automatically on occurrence of one
of the data-modification operations. A trigger is a database object directly associated with a particular table. It fires
whenever a specific statement/type of statement is issued against that table. The types of statements are
insert,update,delete and query statements. Basically, trigger is a set of SQL statements A trigger is a solution to the
restrictions of a constraint.

What is “index covering” of a query?


Index covering means that “Data can be found only using indexes, without touching the tables”

What is a SQL view?

An output of a query can be stored as a view. View acts like small table which meets our criterion. View is a precomplied
SQL query which is used to select data from one or more tables. A view is like a table but it doesn’t physically take any
space. View is a good way to present data in a particular format if you use that query quite often. View can also be used to
restrict users from accessing the tables directly.Its mainly used to view the data from various tables.

What is blocking and when it is happening?


Blocking happens when one connection from an application holds a lock and a second connection requires a conflicting lock
type. This forces the second connection to wait, blocked on the first.

How do you implement one-to-one, one-to-many and many-to-many relationships while designing tables?

One-to-One relationship can be implemented as a single table and rarely as two tables with primary and foreign key
relationships.One-to-Many relationships are implemented by splitting the data into two tables with primary key and foreign
key relationships.Many-to-Many relationships are implemented using a junction table with the keys from both the tables
forming the composite primary key of the junction table.

NETWORKING:
1. What are 10Base2, 10Base5 and 10BaseT Ethernet LANs
10Base2—An Ethernet term meaning a maximum transfer rate of 10 Megabits per second that uses baseband
signaling, with a contiguous cable segment length of 100
meters and a maximum of 2 segments.
10Base5—An Ethernet term meaning a maximum transfer rate of 10 Megabits per second that uses baseband
signaling, with 5 continuous segments not exceeding 100
meters per segment.
10BaseT—An Ethernet term meaning a maximum transfer rate of 10 Megabits per second that uses baseband
signaling and twisted pair cabling.

2. Explain the difference between an unspecified passive open and a fully specified passive open
An unspecified passive open has the server waiting for a connection request from a client. A fully specified passive
open has the server waiting for a connection from a
specific client.

3. Explain the function of Transmission Control Block


A TCB is a complex data structure that contains a considerable amount of information about each connection.

4. Explain a Management Information Base (MIB)


A Management Information Base is part of every SNMP-managed device. Each SNMP agent has the MIB database that
contains information about the device’s status, its
performance, connections, and configuration. The MIB is queried by SNMP.

5. Explain anonymous FTP and why would you use it


Anonymous FTP enables users to connect to a host without using a valid login and password. Usually, anonymous FTP
uses a login called anonymous or guest, with the
password usually requesting the user’s ID for tracking purposes only. Anonymous FTP is used to enable a large number
of users to access files on the host without having
to go to the trouble of setting up logins for them all. Anonymous FTP systems usually have strict controls over the areas
an anonymous user can access.

6. Explain a pseudo tty


A pseudo tty or false terminal enables external machines to connect through Telnet or rlogin. Without a pseudo tty, no
connection can take place.

7. Explain REX
What advantage does REX offer other similar utilities

8. What does the Mount protocol do


The Mount protocol returns a file handle and the name of the file system in which a requested file resides. The message
is sent to the client from the server after reception
of a client’s request.

9. Explain External Data Representation


External Data Representation is a method of encoding data within an RPC message, used to ensure that the data is not
system-dependent.
10. Explain the Network Time Protocol ?

11. BOOTP helps a diskless workstation boot. How does it get a message to the network looking for its IP address and the
location of its operating system boot files
BOOTP sends a UDP message with a subnetwork broadcast address and waits for a reply from a server that gives it the IP
address. The same message might contain the name of the machine that has the boot files on it. If the boot image location
is not specified, the workstation sends another UDP message to query the server.

12. Explain a DNS resource record


A resource record is an entry in a name server’s database. There are several types of resource records used, including
name-to-address resolution information. Resource records are maintained as ASCII files.
13. What protocol is used by DNS name servers
DNS uses UDP for communication between servers. It is a better choice than TCP because of the improved speed a
connectionless protocol offers. Of course, transmission reliability suffers with UDP.

14. Explain the difference between interior and exterior neighbor gateways
Interior gateways connect LANs of one organization, whereas exterior gateways connect the organization to the outside
world.

15. Explain the HELLO protocol used for


The HELLO protocol uses time instead of distance to determine optimal routing. It is an alternative to the Routing
Information Protocol.

16. What are the advantages and disadvantages of the three types of routing tables
The three types of routing tables are fixed, dynamic, and fixed central. The fixed table must be manually modified every
time there is a change. A dynamic table changes its information based on network traffic, reducing the amount of manual
maintenance. A fixed central table lets a manager modify only one table, which is then read by other devices. The fixed
central table reduces the need to update each machine’s table, as with the fixed table. Usually a dynamic table causes the
fewest problems for a network
administrator, although the table’s contents can change without the administrator being aware of the change.

17. Explain a TCP connection table

18. Explain source route


It is a sequence of IP addresses identifying the route a datagram must follow. A source route may
optionally be included in an IP datagram header.

19. Explain RIP (Routing Information Protocol)


It is a simple protocol used to exchange information between the routers.

20. Explain SLIP (Serial Line Interface Protocol)


It is a very simple protocol used for transmission of IP datagrams across a serial line.

21. Explain Proxy ARP


It is using a router to answer ARP requests. This will be done when the originating host believes that a destination is local,
when in fact is lies beyond router.

22. Explain OSPF


It is an Internet routing protocol that scales well, can route traffic along multiple paths, and uses knowledge of an Internet’s
topology to make accurate routing decisions.

23. Explain Kerberos


It is an authentication service developed at the Massachusetts Institute of Technology. Kerberos uses encryption to prevent
intruders from discovering passwords and gaining unauthorized access to files.

24. Explain a Multi-homed Host


It is a host that has a multiple network interfaces and that requires multiple IP addresses is called as a Multi-homed Host.

25. Explain NVT (Network Virtual Terminal)


It is a set of rules defining a very simple virtual terminal interaction. The NVT is used in the start of a Telnet session.
26. Explain Gateway-to-Gateway protocol
It is a protocol formerly used to exchange routing information between Internet core routers.

27. Explain BGP (Border Gateway Protocol)


It is a protocol used to advertise the set of networks that can be reached with in an autonomous system. BGP enables this
information to be shared with the autonomous system. This is newer than EGP (Exterior Gateway Protocol).
28. Explain autonomous system
It is a collection of routers under the control of a single administrative authority and that uses a common Interior Gateway
Protocol.

29. Explain EGP (Exterior Gateway Protocol)


It is the protocol the routers in neighboring autonomous systems use to identify the set of networks that can be reached
within or via each autonomous system.

30. Explain IGP (Interior Gateway Protocol)


It is any routing protocol used within an autonomous system.

31. Explain Mail Gateway


It is a system that performs a protocol translation between different electronic mail delivery protocols.

32. Explain wide-mouth frog


Wide-mouth frog is the simplest known key distribution center (KDC) authentication protocol.

33. What are Digrams and Trigrams


The most common two letter combinations are called as digrams. e.g. th, in, er, re and an. The most common three letter
combinations are called as trigrams. e.g. the, ing, and, and ion.
34. Explain silly window syndrome
It is a problem that can ruin TCP performance. This problem occurs when data are passed to the sending TCP entity in large
blocks, but an interactive application on the receiving side reads 1 byte at a time.
35. Explain region
When hierarchical routing is used, the routers are divided into what we call regions, with each router knowing all the details
about how to route packets to destinations within its own region, but knowing nothing about the internal structure of other
regions.
36. Explain multicast routing
Sending a message to a group is called multicasting, and its routing algorithm is called multicast routing.
37. Explain traffic shaping
One of the main causes of congestion is that traffic is often busy. If hosts could be made to transmit at a uniform rate,
congestion would be less common. Another open loop method to help manage congestion is forcing the packet to be
transmitted at a more predictable rate. This is called traffic shaping.
38. Explain packet filter
Packet filter is a standard router equipped with some extra functionality. The extra functionality allows every incoming or
outgoing packet to be inspected. Packets meeting some criterion are forwarded normally. Those that fail the test are
dropped.
39. Explain virtual path
Along any transmission path from a given source to a given destination, a group of virtual circuits can be grouped together
into what is called path.
40. Explain virtual channel
Virtual channel is normally a connection from one source to one destination, although multicast connections are also
permitted. The other name for virtual channel is virtual circuit.
41. Explain logical link control
One of two sublayers of the data link layer of OSI reference model, as defined by the IEEE 802 standard. This sublayer is
responsible for maintaining the link between computers when they are sending data across the physical network connection.
42. Why should you care about the OSI Reference Model
It provides a framework for discussing network operations and design.
43. Explain the difference between routable and non- routable protocols
Routable protocols can work with a router and can be used to build large networks. Non-Routable protocols are designed to
work on small, local networks and cannot be used with a router
44. Explain MAU
In token Ring , hub is called Multistation Access Unit(MAU).
45. Explain 5-4-3 rule
In a Ethernet network, between any two points on the network, there can be no more than five network segments or four
repeaters, and of those five segments only three of segments can be populated.
46. Explain the difference between TFTP and FTP application layer protocols
The Trivial File Transfer Protocol (TFTP) allows a local host to obtain files from a remote host but does not provide reliability
or security. It uses the fundamental packet delivery services offered by UDP.
The File Transfer Protocol (FTP) is the standard mechanism provided by TCP / IP for copying a file from one host to another.
It uses the services offered by TCP and so is reliable and secure. It establishes two connections (virtual circuits) between
the hosts, one for data transfer and another for control information.
47. Explain the range of addresses in the classes of internet addresses
Class A 0.0.0.0 - 127.255.255.255
Class B 128.0.0.0 - 191.255.255.255
Class C 192.0.0.0 - 223.255.255.255
Class D 224.0.0.0 - 239.255.255.255
Class E 240.0.0.0 - 247.255.255.255
48. Explain the minimum and maximum length of the header in the TCP segment and IP datagram
The header should have a minimum length of 20 bytes and can have a maximum length of 60 bytes.
49. Explain difference between ARP and RARP
The address resolution protocol (ARP) is used to associate the 32 bit IP address with the 48 bit physical address, used by a
host or a router to find the physical address of another host on its network by sending a ARP query packet that includes the
IP address of the receiver. The reverse address resolution protocol (RARP) allows a host to discover its Internet address
when it knows only its physical address.
50. Explain ICMP
ICMP is Internet Control Message Protocol, a network layer protocol of the TCP/IP suite used by hosts and gateways to send
notification of datagram problems back to the sender. It uses the echo test / reply to test whether a destination is reachable
and responding. It also handles both control and error messages.
51. What are the data units at different layers of the TCP / IP protocol suite
The data unit created at the application layer is called a message, at the transport layer the data unit created is called either
a segment or an user datagram, at the network layer the data unit created is called the datagram, at the data link layer the
datagram is encapsulated in to a frame and
finally transmitted as signals along the transmission media.
52. Explain Project 802
It is a project started by IEEE to set standards that enable intercommunication between equipment from a variety of
manufacturers. It is a way for specifying functions of the physical layer, the data link layer and to some extent the network
layer to allow for interconnectivity of major LAN protocols.
It consists of the following:
802.1 is an internetworking standard for compatibility of different LANs and MANs across protocols.
802.2 Logical link control (LLC) is the upper sublayer of the data link layer which is non-architecture-specific, that is
remains the same for all IEEE-defined LANs.
Media access control (MAC) is the lower sublayer of the data link layer that contains some distinct modules each carrying
proprietary information specific to the LAN product being used. The modules are Ethernet LAN (802.3), Token ring LAN
(802.4), Token bus LAN (802.5).
802.6 is distributed queue dual bus (DQDB) designed to be used in MANs.
53. Explain Bandwidth
Every line has an upper limit and a lower limit on the frequency of signals it can carry. This limited range is called the
bandwidth.
54. Difference between bit rate and baud rate.
Bit rate is the number of bits transmitted during one second whereas baud rate refers to the number of signal units per
second that are required to represent those bits. baud rate = bit rate / N where N is no-of-bits represented by each signal
shift.
55. Explain MAC address
The address for a device as it is identified at the Media Access Control (MAC) layer in the network architecture. MAC address
is usually stored in ROM on the networkadapter card and is unique.
56. Explain attenuation
The degeneration of a signal over distance on a network cable is called attenuation.

57. Explain cladding


A layer of a glass surrounding the center fiber of glass inside a fiber-optic cable.

58. Explain RAID


A method for providing fault tolerance by using multiple hard disk drives.

59. Explain NETBIOS and NETBEUI


NETBIOS is a programming interface that allows I/O requests to be sent to and received from a remote computer and it
hides the networking hardware from applications. NETBEUI is NetBIOS extended user interface. A transport protocol
designed by microsoft and IBM for the use on small subnets.

60. Explain redirector


Redirector is software that intercepts file or prints I/O requests and translates them into network requests. This comes
under presentation layer.
61. Explain Beaconing
The process that allows a network to self-repair networks problems. The stations on the network notify the other stations on
the ring when they are not receiving the transmissions. Beaconing is used in Token ring and FDDI networks.
62. Explain terminal emulation, in which layer it comes
Telnet is also called as terminal emulation. It belongs to application layer.

63. Explain frame relay, in which layer it comes


Frame relay is a packet switching technology. It will operate in the data link layer.
64. What do you meant by “triple X” in Networks
The function of PAD (Packet Assembler Disassembler) is described in a document known as X.3. The standard protocol has
been defined between the terminal and the PAD, called X.28; another standard protocol exists between hte PAD and the
network, called X.29. Together, these three recommendations are often called “triple X”
65. Explain SAP
Series of interface points that allow other computers to communicate with the other layers of network protocol stack.

66. Explain subnet


A generic term for section of a large networks usually separated by a bridge or router.

67. Explain Brouter


Hybrid devices that combine the features of both bridges and routers.

68. How Gateway is different from Routers


A gateway operates at the upper levels of the OSI model and translates information between two completely different
network architectures or data formats.

69. What are the different type of networking / internetworking devices


Repeater: Also called a regenerator, it is an electronic device that operates only at physical layer. It receives the signal in
the network before it becomes weak, regenerates the original bit pattern and puts the refreshed copy back in to the link.
Bridges: These operate both in the physical and data link layers of LANs of same type. They divide a larger network in to
smaller segments. They contain logic that allow them to keep the traffic for each segment separate and thus are repeaters
that relay a frame only the side of the segment containing the intended recipent and control congestion.
Routers: They relay packets among multiple interconnected networks (i.e. LANs of different type). They operate in the
physical, data link and network layers. They contain software that enable them to determine which of the several possible
paths is the best for a particular transmission.
Gateways:
They relay packets among networks that have different protocols (e.g. between a LAN and a WAN). They accept a packet
formatted for one protocol and convert it to a packet formatted for another protocol before forwarding it. They operate in all
seven layers of the OSI model.
70. Explain mesh network
A network in which there are multiple network links between computers to provide multiple paths for data to travel.
71. Explain passive topology
When the computers on the network simply listen and receive the signal, they are referred to as passive because they don’t
amplify the signal in any way. Example for passive topology - linear bus.

72. What are the important topologies for networks


BUS topology:
In this each computer is directly connected to primary network cable in a single line.
Advantages:
Inexpensive, easy to install, simple to understand, easy to extend.
STAR topology:
In this all computers are connected using a central hub.
Advantages:
Can be inexpensive, easy to install and reconfigure and easy to trouble shoot physical problems.
RING topology:
In this all computers are connected in loop.
Advantages:
All computers have equal access to network media, installation can be simple, and signal does not degrade as much as
in other topologies because each computer
regenerates it.

73. What are major types of networks and explain


Server-based network
Peer-to-peer network
Peer-to-peer network, computers can act as both servers sharing resources and as clients using the resources.
Server-based networks provide centralized control of network resources and rely on server computers to provide security
and network administration

74. Explain Protocol Data Unit


The data unit in the LLC level is called the protocol data unit (PDU). The PDU contains of four fields a destination service
access point (DSAP), a source service access point (SSAP), a control field and an information field. DSAP, SSAP are
addresses used by the LLC to identify the protocol stacks on the receiving and sending machines that are generating and
using the data. The control field specifies whether the PDU frame is a information frame (I - frame) or a supervisory frame
(S - frame) or a
unnumbered frame (U - frame).
75. Explain difference between baseband and broadband transmission
In a baseband transmission, the entire bandwidth of the cable is consumed by a single signal. In broadband transmission,
signals are sent on multiple frequencies, allowing multiple signals to be sent simultaneously.
76. What are the possible ways of data exchange
(i) Simplex (ii) Half-duplex (iii) Full-duplex.

77. What are the types of Transmission media


Signals are usually transmitted over some transmission media that are broadly classified in to two categories.
Guided Media:
These are those that provide a conduit from one device to another that include twisted-pair, coaxial cable and fiber-optic
cable. A signal traveling along any of these media is directed and is contained by the physical limits of the medium.
Twisted-pair and coaxial cable use metallic that accept
and transport signals in the form of electrical current. Optical fiber is a glass or plastic cable that accepts and transports
signals in the form of light.
Unguided Media:
This is the wireless media that transport electromagnetic waves without using a physical conductor. Signals are broadcast
either through air. This is done through radio communication, satellite communication and cellular telephony.
78. Explain point-to-point protocol
A communications protocol used to connect computers to remote networking services including Internet service providers.
79. What are the two types of transmission technology available
(i) Broadcast and (ii) point-to-point

80. Difference between the communication and transmission.


Transmission is a physical movement of information and concern issues like bit polarity, synchronization, clock etc.
Communication means the meaning full exchange of information between two communication media.

Вам также может понравиться