Skip to main content

Page IV - Java Interview Questions With Answers.

76. What Is Function Overriding?

Answer: If a subclass provides a specific implementation of a method that is already provided by its parent class, it is known as Method Overriding.

77. Difference Between Overloading & Overriding?

Answer: Method overloading increases the readability of the program. Method overriding provides the specific implementation of the method that is already provided by its super class parameter must be different in case of overloading, parameter must be same in case of overriding.

78. What Is Final Class?

Answer: Final classes are created so the methods implemented by that class cannot be overridden. It can’t be inherited.

79. What Is NullPointerException?

Answer: A NullPointerException is thrown when calling the instance method of a null object, accessing or modifying the field of a null object etc.

80. What Are The Ways In Which A Thread Can Enter The Waiting State?

Answer: A thread can enter the waiting state by invoking its sleep method, by blocking on IO, 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.

81. How Does Multithreading Take Place On A Computer With A Single CPU?

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

82. What Invokes A Thread's Run Method?

Answer: After a thread is started, via its start method of the Thread class, the JVM invokes the thread's run method when the thread is initially executed.

83. Does It Matter In What Order Catch Statements For FileNotFoundException & IOException Are Written?

Answer: Yes, it does. The FileNoFoundException is inherited from the IOException. Exception's subclasses have to be caught first.

84. What Is The Difference Between Yielding & Sleeping?

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

85. Why Vector Class Is Used?

Answer: The Vector class provides the capability to implement a growable array of objects. Vector proves to be very useful if you don't know the size of the array in advance, or you just need one that can change sizes over the lifetime of a program.

86. How Many Bits Are Used To Represent Unicode, ASCII, UTF-16, & UTF-8 Characters?

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

87. What Are Wrapper Classes?

Answer: These are classes that allow primitive types to be accessed as objects. Example: Integer, Character, Double, Boolean etc.

88. What Is The Difference Between A Window & A Frame?

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

89. Which Package Has Light Weight Components?

Answer: javax.Swing package. All components in Swing, except JApplet, JDialog, JFrame and JWindow are lightweight components.

90. What Is The Difference Between The paint & repaint Methods?

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

91. What Is The Purpose Of File Class?

Answer: It is used to create objects that provide access to the files and directories of a local file system.

92. What Is The Difference Between The Reader/Writer Class Hierarchy & The InputStream/OutputStream Class Hierarchy?

Answer: The Reader/Writer class hierarchy is character-oriented, and the InputStream/OutputStream class hierarchy is byte-oriented.

93. Which Class Should You Use To Obtain Design Information About An Object?

Answer: The Class class is used to obtain information about an object's design and java.lang.Class class instance represent classes, interfaces in a running Java application.

94. What Is The Difference Between Static & Nonstatic Variables?

Answer: A static variable is associated with the class as a whole rather than with specific instances of a class. Nonstatic variables take on unique values with each object instance.

95. What Is Serialization & Deserialization?

Answer: Serialization is the process of writing the state of an object to a byte stream. Deserialization is the process of restoring these objects.

96. What Are Use Cases?

Answer: It is part of the analysis of a program and describes a situation that a program might encounter  and what behavior the program should exhibit in that circumstance.

97. Explain The Use Of subclass In A Java Program?

Answer: Subclass inherits all the public and protected methods and the implementation. It also inherits all the default modifier methods and their implementation.

98. How To Add Menu Shortcut To Menu Item?

Answer: If there is a button instance called b1, you may add menu shortcut by calling b1.setMnemonic ′F′, so the user may be able to use Alt+F to click the button.

99. Can You Write A Java Class That Could Be Used Both As An Applet As Well As An Application?

Answer: Yes, just add a main method to the applet.

100. What Is The Difference Between Swing & AWT Components?

Answer: AWT components are heavyweight, whereas Swing components are lightweight. Heavyweight components depend on the local windowing toolkit. For example, java.awt.Button is a heavyweight component, when it is running on the Java platform for Unix platform, it maps to a real Motif button.


Check Out Other Questions As Well: -


101. What's The Difference Between Constructors & Other Methods?
102. Is There Any Limitation Of Using Inheritance?
103. When Is The ArrayStoreException Thrown?
104. Can You Call One Constructor From Another If A Class Has Multiple Constructors?
105. What's The Difference Between The Methods Sleep & Wait?

106. When ArithmeticException Is Thrown?
107. What Is A Transient Variable?
108. What Is Synchronization?
109. What Is The Collections API?
110. Does Garbage Collection Guarantee That A Program Will Not Run Out Of Memory?

111. What Is The Immediate Superclass Of The Applet Class?
112. Which Java Operator Is Right Associative?
113. What Is The Difference Between A Break Statement & A Continue Statement?
114. If A Variable Is Declared As Private, Where May The Variable Be Accessed?
115. What Is The Purpose Of The System Class?

116. List Primitive Java Types?
117. What Is The Relationship Between Clipping & Repainting Under AWT?
118. Which Class Is The Immediate Superclass Of The Container Class?
119. What Class Of Exceptions Are Generated By The Java Run-Time System?
120. Under What Conditions Is An Object's Finalize Method Invoked By The Garbage Collector?

121. How Can A Dead Thread Be Restarted?
122. Which Arithmetic Operations Can Result In The Throwing Of An ArithmeticException? Variable Of The Boolean Type Is Automatically Initialized As?
123. How Does A Try Statement Determine Which Catch Clause Should Be Used To Handle An Exception? Can Try Statements Be Nested?
124. Is It Necessary That Each Try Block Must Be Followed By A Catch Block?
125. What Are Class Loaders?

...Return To Java FAQ's Section


Comments

  1. Ni Hau,


    Gasping at your brilliance! Thanks a tonne for sharing all that content. Can’t stop reading. Honestly!


    I create an instance of javax.xml.transform.TransformerFactory and directly afterwards I parse a xsltSource:

    Java Code:
    1
    2
    3
    4
    5
    6
    7 protected synchronized Transformer getTransformer(Source xsltSource)
    throws TransformerConfigurationException {

    TransformerFactory transformerFactory = TransformerFactory.newInstance();
    Transformer transformer = transformerFactory.newTransformer(xsltSource);
    return transformer;
    }
    I am using the com.sun.org.apache.xalan.internal.xsltc.trax.Trans formerFactoryImpl com.sun.org.apache.xalan.internal.xsltc.trax.Trans formerImpl classes.
    Which are the ones provided by the JDK.




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