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

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