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

What Is (Are) Your Weakness (Weaknesses)? - Interview Answers

There’s a saying – “However small the thorn maybe it has the ability to pierce.” Never say you are a Workaholic, a Perfectionist, etc. because it sounds negative. Try to convert these negative biased qualities into positive ones. For Example, In   place of Workaholic you can say you are a hard worker and always willing to work for extra hours. In place of Perfectionist , you can say you are detail oriented and like to set high standard for work. “Try to specify your weakness as your strength and also highlight it as a benefit.” Your answers can be: 1) One of my weaknesses as I perceive is occasional compromise on time for quality and perfection. 2) I feel I am not very detail-oriented . I’m a person that wants accomplish as much as possible. I realized this hurts quality and therefore I‘m trying hard to find a balance between quality and quantity. 3) At times even when I need help, I try to solve my own problems instead of asking a co-worker who might know...

What Is (Are) Your Strengths? - Interview Answers

This is a simple and popular interview question. Generally people answer it in two ways. There are people who simply state their strength like “I am Young, Dynamic, Intelligent, Smart and so on…”. Such answer is neither right nor wrong but does not help u in any way also. Secondly there are peoples who state their strengths and explain them how he can use his strength for the job and industry. Do not simply state your strength. Everyone has some strength, all you need is to convert them into benefits. In short, try to advertise yourself by converting your features into strengths. “EVERYONE CLAIM THEY ARE HONEST, HARDWORKING, SMART AND SO ON….. BUT WITH AN EXAMPLE IT IS MUCH MORE BELIEVABLE.” Your answers can be : 1) I am a hard worker and because of this ability I can work for additional hours to accomplish my tasks.I am commitment oriented and hence I always enjoy the trust and confidence of my team mates which enables me to perform my duties very easily. 2) I am a...