Skip to main content

Page VII - Java Interview Questions With Answers.

151. What Are Order Of Precedence & Associativity & How Are They Used?

Answer: Order of precedence determines the order in which operators are evaluated in expressions. Associativity determines whether an expression is evaluated left-to-right or right-to-left.

152. What Is Type Casting? What Is Downcasting? Can A Double Value Be Cast To A Byte?

Answer: Type casting means treating a variable of one type as though it is another type.
Downcasting is the casting from a general to a more specific type, i.e. casting down the hierarchy.

Yes, a double value can be cast to a byte.

153. Which Method Of The Component Class Is Used To Set The Position & Size Of A Component?

Answer: setBounds method is used for this purpose.

154. What Is The Range Of The Short Type?

Answer: The range of the short type is -2^15 to 2^15 - 1.

155. What Is The Immediate Superclass Of Menu?

Answer: MenuItem class

156. Does Java Allow Default Arguments?

Answer: No, Java does not allow Default Arguments.

157. Which Number Is Denoted By Leading Zero In Java? Which Number Is Denoted By Leading 0x Or 0X In Java?

Answer: Octal Numbers are denoted by leading zero in java, example: 06

Hexadecimal Numbers are denoted by leading 0x or 0X in java, example − 0XF

158. Break Statement Can Be Used As Labels In Java?

Answer: Yes, an example can be break one;

159. Where Import Statement Is Used In A Java Program?

Answer: Import statement is allowed at the beginning of the program file after package statement.

160. What Are The Steps Involved In A  Life Cycle Of An Applet?

Answer: Life cycle involves the following steps:
  • Initialization
  • Starting
  • Stopping
  • Destroying
  • Painting

161. Why Is The Role Of init Method Under Applets?

Answer: It initializes the applet and is the first method to be called.

162. Which Method Is Called By Applet Class To Load An Image?

Answer: getImageURLobject, filename is used for this purpose.

163. Define Code As An Attribute Of Applet?

Answer: It is used to specify the name of the applet class.

164. Define Canvas?

Answer: It is a simple drawing surface which are used for painting images or to perform other graphical operations.

165. Define Network Programming?

Answer: It refers to writing programs that execute across multiple devices computers, in which the devices are all connected to each other using a network.

166. What Is A Socket? State The Advantages & Disadvantages Of Sockets?

Answer: Sockets provide the communication mechanism between two computers using TCP. A client program creates a socket on its end of the communication and attempts to connect that socket to a server.

Advantage: Sockets are flexible and sufficient. Efficient socket based programming can be easily implemented for general communications. It cause low network traffic.

Disadvantage: Socket based communications allows only to send packets of raw data between applications. Both the client-side and server-side have to provide mechanisms to make the data useful in any way.

167. Which Class Is Used By Server Applications To Obtain A Port & Listen For Client Requests?

Answer: java.net.ServerSocket class is used by server applications to obtain a port and listen for client requests

168. Which Class Represents The Socket That Both The Client & Server Use To Communicate With Each Other?

Answer: java.net.Socket class represents the socket that both the client and server use to communicate with each other.

169. Why Generics Are Used In Java?

Answer: Generics provide compile-time type safety that allows programmers to catch invalid types at compile time. Java Generic methods and generic classes enable programmers to specify, with a single method declaration, a set of related methods or, with a single class declaration, a set of related types.

170. What Environment Variables Do I Need To Set On My Machine In Order To Be Able To Run Java Programs?

Answer: CLASSPATH and PATH are the two variables.

171. Is There Any Need To Import java.lang Package?

Answer: No, there is no need to import this package. It is by default loaded internally by the JVM.

172. What Is Externalizable Interface?

Answer: Externalizable is an interface which contains two methods readExternal and writeExternal. These methods give you a control over the serialization mechanism.

173. If System.exit 0; Is Written At The End Of The Try Block, Will The Finally Block Still Execute?

Answer: No in this case the finally block will not execute because when you say System.exit 0; the control immediately goes out of the program, and thus finally never executes.

174. What Is The GregorianCalendar Class?

Answer: The GregorianCalendar provides support for traditional Western calendars

175. What Is The SimpleTimeZone Class?

Answer: The SimpleTimeZone class provides support for a Gregorian calendar .

Check Out Other Questions As Well: -


176. What Is The Difference Between The Size & Capacity Of A Vector?
177. Can A Vector Contain Heterogenous Objects?
178. What Is An Enumeration?
179. What Is Difference Between Path & Classpath?
180. Can A Class Declared As Private Be Accessed Outside It's Package?

181. What Are The Restriction Imposed On A Static Method Or A Static Block Of Code?
182. What Is An Object's Lock & Which Object's Have Locks?
183. What Is The Difference Between Inner Class & Nested Class?
184. What Restrictions Are Placed On Method Overriding?
185. What Will Be The Default Values Of All The Elements Of An Array Defined As An Instance Variable?

...Return To Java FAQ's Section

Comments

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