Skip to main content

Page V - Java Interview Questions With Answers.

101. What's The Difference Between Constructors & Other Methods?

Answer: Constructors must have the same name as the class and can not return a value. They are only called once while regular methods could be called many times.

102. Is There Any Limitation Of Using Inheritance?

Answer: Yes, since inheritance inherits everything from the super class and interface, it may make the subclass too clustering and sometimes error-prone when dynamic overriding or dynamic overloading in some situation.

103. When Is The ArrayStoreException Thrown?

Answer: When copying elements between different arrays, if the source or destination arguments are not arrays or their types are not compatible, an ArrayStoreException will be thrown.

104. Can You Call One Constructor From Another If A Class Has Multiple Constructors?

Answer: Yes, use this syntax.

105. What's The Difference Between The Methods Sleep & Wait?

Answer: The code sleep2000; puts thread aside for exactly two seconds. The code wait2000, causes a wait of up to two second. A thread could stop waiting earlier if it receives the notify or notifyAll call. The method wait is defined in the class Object and the method sleep is defined in the class Thread.

106. When ArithmeticException Is Thrown?

Answer: The ArithmeticException is thrown when integer is divided by zero or taking the remainder of a number by zero. It is never thrown in floating-point operations.

107. What Is A Transient Variable?

Answer: A transient variable is a variable that may not be serialized during Serialization and which is initialized by its default value during de-serialization,

108. What Is Synchronization?

Answer: Synchronization is the capability to control the access of multiple threads to shared resources. synchronized keyword in java provides locking which ensures mutual exclusive access of shared resource and prevent data race.

109. What Is The Collections API?

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

110. Does Garbage Collection Guarantee That A Program Will Not Run Out Of Memory?

Answer: 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.

111. What Is The Immediate Superclass Of The Applet Class?

Answer: Panel is the immediate superclass. A panel provides space in which an application can attach any other component, including other panels.

112. Which Java Operator Is Right Associative?

Answer: The = operator is right associative.

113. What Is The Difference Between A Break Statement & A Continue Statement?

Answer: 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.

114. If A Variable Is Declared As Private, Where May The Variable Be Accessed?

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

115. What Is The Purpose Of The System Class?

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

116. List Primitive Java Types?

Answer: The eight primitive types are byte, char, short, int, long, float, double, and boolean.

117. What Is The Relationship Between Clipping & Repainting Under AWT?

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

118. Which Class Is The Immediate Superclass Of The Container Class?

Answer: Component class is the immediate super class.

119. What Class Of Exceptions Are Generated By The Java Run-Time System?

Answer: The Java runtime system generates RuntimeException and Error exceptions.

120. Under What Conditions Is An Object's Finalize Method Invoked By The Garbage Collector?

Answer: The garbage collector invokes an object's finalize method when it detects that the object has
become unreachable.

121. How Can A Dead Thread Be Restarted?

Answer: A dead thread cannot be restarted.

122. Which Arithmetic Operations Can Result In The Throwing Of An ArithmeticException? Variable Of The Boolean Type Is Automatically Initialized As?

Answer: Integer / and % can result in the throwing of an ArithmeticException. The default value of the boolean type is false.

123. How Does A Try Statement Determine Which Catch Clause Should Be Used To Handle An Exception? Can Try Statements Be Nested?

Answer: 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.

Yes, try statement can be nested.

124. Is It Necessary That Each Try Block Must Be Followed By A Catch Block?

Answer: It is not necessary that each try block must be followed by a catch block. It should be followed by either a catch block or a finally block.

125. What Are Class Loaders?

Answer: A class loader is an object that is responsible for loading classes. The class ClassLoader is an abstract class.


Check Out Other Questions As Well: -


126. What Is The Difference Between An Interface & An Abstract Class?
127 .Can An Interface Extend Another Interface?
128. If A Method Is Declared As Protected, Where May The Method Be Accessed?
129. What Will Happen If Static Modifier Is Removed From The Signature Of The Main Method?
130. What Is The Default Value Of An Object Reference Declared As An Instance Variable?

131. What Is Nested Top-Level Class? Can A Top Level Class Be Private Or Protected?
132 .Why Do We Need wrapper Classes?
133. What Is The Difference Between Error & An Exception?
134. Describe Life Cycle Of Thread?
135. When A Thread Is Created & Started, What Is Its Initial State?

136. Explain Suspend, isAlive Method Under Thread Class? What Is currentThread?
137. Explain Main Thread Under Thread Class Execution?
138. What Is Daemon Thread? Which Method Is Used To Create The Daemon Thread? Which Method Must Be Implemented By All Threads?
139. What Is The Locale Class?
140. What Are Synchronized Methods & Synchronized Statements?

141. What Is Runtime Polymorphism Or Dynamic Method Dispatch?
142. Which Object Oriented Concept Is Achieved By Using Overloading & Overriding?
143. What Is Dynamic Binding?
144. Can Constructor Be Inherited? Where & How Can You Use A Private Constructor?
145. What Is Constructor Chaining & How Is It Achieved In Java?

146. What Are The Advantages Of ArrayList Over Arrays?
147. Why Deletion In LinkedList Is Fast Than ArrayList?
148. How Do You Decide When To Use ArrayList & LinkedList?
149. What Is A Values Collection View ?
150. What Is Dot Operator? What Is The Difference Between The >> and >>> Operators?

...Return To Java FAQ's Section

Comments

  1. thnk u so much all java question are very helpful in my interview

    ReplyDelete

Post a Comment

Please share your opinions and suggestions or your experience in the comments section. This way we can all help each other...

Experienced guys can share their resumes at admin@interview-made-easy.com

Popular posts from this blog

Tell Me Something About Yourself - Interview Answers.

Try to introduce some of your most important employment-oriented skills as well as your education and accomplishments to the interviewer. Answer to this question is very important because it positions you for the rest of the interview . That's why this statement is often called the "Positioning Statement". One should take the opportunity to show his/her communication skills by speaking clearly and concisely in an organized manner. Since there is no right or wrong answer for this question hence it is important to appear friendly. YOUR ANSWERS CAN BE: 1) I am a person with strong interpersonal skills and have the ability to get along well with people . I enjoy challenges and looking for creative solutions to problems. 2) Besides the details given in my resume, I believe in character values, vision and action. I am quick in learning from mistakes. I am confident that the various tests that you have conducted will corroborate my competencies apti...

HR Interview Questions With Simple Answers - Top 30.

Here are some very important HR questions which are often asked during Interviews and I believe these answers can really help you to get through....... Click on them to view the answer: 1) Tell Me Something About Yourself ? 2) What Are Your Strengths? 3) What Are Your Weaknesses? 4) How Do You Handle Pressure / Can You Work Well Under Pressure? 5) What Are Your Short Term Goals? 6) What Are Your Long Term Goals? 7) Where Do You See After 5 Years? 8) Why Should We Hire You? 9) What Is Your Salary Expectation? 10) Why Do You Want To Leave Your Current Job? 11) Do You Prefer To Work Alone Or As A Team Player? 12) What Made You Choose Your Major / Stream? 13) Why Didn’t You Pursue A Career In Your Major / Stream? 14) Why Do You Want To Work For Us? 15) Are You Willing To Travel? 16) Are You Willing To Take Risks? 17) What Do You Know About This Company? 18) What Do You Seek From A Job? 19) How Do You Evaluate Success? 20) Dur...

Sample Cover Letter / Job Application.

To The General Manager (HR) [ Name and Designation (Bold Words)] Infosys Limited Delhi – 110001 Uttam Agrawal Gandhi Chowk, Bhartee Street [ Name Bhawanipatna, Kalahandi Contact Address Orissa – 766001 Telephone No.] Ph. no - +91-9438170446 [Sub: Application for the position of ___________ in your esteemed organization.] Respected Sir, (Always use ‘Respected’) With reference to your advertisement dated 14th may’ 08 in The Times of India for the position of ___________ . I would like to place myself as a strong contender before you. OR This has reference to your advertisement dated 14th may’ 08 in The Times of India for the position of ____________. In the said connection I take this opportunity to apply for the said position as a strong contender. /*This is the Introduction i.e the first paragraph of your application/* ( Now the Second Paragraph is the Self Introduction) Try to start the second paragraph with the below mentioned lines: - I have the p...