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

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