Skip to main content

Page III - Java Interview Questions With Answers.

51. What Is An Interface?

Answer:  An interface is a collection of abstract methods. A class implements an interface, thereby
inheriting the abstract methods of the interface.

52. Give Some Features Of Interface?

Answer: Some features of interfaces are:
  • Interface cannot be instantiated
  • An interface does not contain any constructors.
  • All of the methods in an interface are abstract.

53. Define Packages In Java?

Answer: A Package can be defined as a grouping of related types, classes, interfaces, enumerations and annotations providing access protection and name space management.

54. Why Packages Are Used?

Answer: Packages are used in Java in-order to prevent naming conflicts, to control access, to make searching/locating and usage of classes, interfaces, enumerations and annotations, etc., easier.

55. What Do You Mean By Multithreaded Program?

Answer: A multithreaded program contains two or more parts that can run concurrently. Each part of such a program is called a thread, and each thread defines a separate path of execution.

56. What Are The Two Ways In Which Thread Can Be Created?

Answer: Thread can be created by: implementing Runnable interface, extending the Thread class.

57. What As An Applet? An Applet Extends Which Class?

Answer: An applet is a Java program that runs in a Web browser. An applet can be a fully functional Java application because it has the entire Java API at its disposal.

An applet extends java.applet.Applet class.

58. Explain Garbage Collection In Java?

Answer: It uses garbage collection to free the memory. By cleaning those objects that is no longer
referenced by any of the program.

59. Define Immutable Object?

Answer:  An immutable object can’t be changed once it is created.

60. Explain The Usage Of This With Constructors?

Answer: It is used with variables or methods and used to call constructor of same class.

61. Explain Set Interface?

Answer: It is a collection of element which cannot contain duplicate elements. The Set interface contains only methods inherited from Collection and adds the restriction that duplicate elements are prohibited.

62. Explain TreeSet?

Answer: It is a Set implemented when we want elements in a sorted order.

63. What Is Comparable Interface?

Answer: It is used to sort collections and arrays of objects using the collections.sort and java.utils. The objects of the class implementing the Comparable interface can be ordered.

64. Difference Between Throw & Throws?

Answer: Throw is used to trigger an exception where as throws is used in declaration of exception.
Without throws, Checked exception cannot be handled whereas checked exception can be propagated with throws.

65. Explain The Following Line Used Under Java Program − public static void main Stringargs[]

Answer: The following shows the explanation individually:
  • public − it is the access specifier.
  • static − it allows main to be called without instantiating a particular instance of a class.
  • void − it affirms the compiler that no value is returned by main.
  • main − this method is called at the beginning of a Java program.
  • String args[ ] − args parameter is an instance array of class String.

66. Define JRE i.e. Java Runtime Environment?

Answer: Java Runtime Environment is an implementation of the Java Virtual Machine which executes Java programs. It provides the minimum requirements for executing a Java application;

67. What Is JAR File?

Answer: JAR files is Java Archive files and it aggregates many files into one. It holds Java classes in a library. JAR files are built on ZIP file format and have .jar file extension.

68. What Is A WAR File?

Answer: This is Web Archive File and used to store XML, java classes, and JavaServer pages. which is used to distribute a collection of JavaServer Pages, Java Servlets, Java classes, XML files, static Web pages etc.

69. Define JIT Compiler?

Answer: It improves the runtime performance of computer programs based on bytecode.

70. What Is The Difference Between Object Oriented Programming Language & Object Based Programming Language?

Answer: Object based programming languages follow all the features of OOPs except Inheritance. JavaScript is an example of object based programming languages.

71. What Is The Purpose Of Default Constructor?

Answer: The java compiler creates a default constructor only if there is no constructor in the class.

72. Can A Constructor Be Made Final?

Answer: No, this is not possible.

73. What Is Static Block?

Answer: It is used to initialize the static data member, It is executed before main method at the time of classloading.

74. Define Composition?

Answer: Holding the reference of the other class within some other class is known as composition.

75. What Is Function Overloading?

Answer: If a class has multiple functions by same name but different parameters, it is known as Method Overloading.


Check Out Other Questions As Well: -


76. What Is Function Overriding?
77. Difference Between Overloading & Overriding?
78. What Is Final Class?
79. What Is NullPointerException?
80. What Are The Ways In Which A Thread Can Enter The Waiting State?

81. How Does Multithreading Take Place On A Computer With A Single CPU?
82. What Invokes A Thread's Run Method?
83. Does It Matter In What Order Catch Statements For FileNotFoundException & IOException Are Written?
84. What Is The Difference Between Yielding & Sleeping?
85. Why Vector Class Is Used?

86. How Many Bits Are Used To Represent Unicode, ASCII, UTF-16, & UTF-8 Characters?
87. What Are Wrapper Classes?
88. What Is The Difference Between A Window & A Frame?
89. Which Package Has Light Weight Components?
90. What Is The Difference Between The paint & repaint Methods?

91. What Is The Purpose Of File Class?
92. What Is The Difference Between The Reader/Writer Class Hierarchy & The InputStream/OutputStream Class Hierarchy?
93. Which Class Should You Use To Obtain Design Information About An Object?
94. What Is The Difference Between Static & Nonstatic Variables?
95. What Is Serialization & Deserialization?

96. What Are Use Cases?
97. Explain The Use Of subclass In A Java Program?
98. How To Add Menu Shortcut To Menu Item?
99. Can You Write A Java Class That Could Be Used Both As An Applet As Well As An Application?
100. What Is The Difference Between Swing & AWT Components?

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