Most commonly asked interview questions on java
1. What is JVM?
JVM stands for Java Virtual Machine and it makes Java a Portable and a Platform Independent Language. JVM is called Virtual as it is an Abstract System that executes Compiled Java Programs. JVM executes the Java ByteCode File or .class file.
2. Enlist Different Packages of Swings.
The different Packages of Swings are as follows:
1. javax.swing: Provides a set of Light-weight Java Language Components.
2. javax.swing.plaf: Provides One interface and Many abstract classes to provide look-and-feel capabilities.
3. javax.swing.plaf.multi: Provides User Interface Objects built for Multi Platform Look and Feel.
4. javax.swing.event: Provides Events Fired by Swing Components.
5. javax.swing.tree: Provides Classes and Interfaces for dealing with javax.awt.swing.JTree
6. javax.swing.undo: Provides support for Undo/Redo Capabilities in Text Editor Applications.
3. Enlist the difference between C++ and Java.
1. Java is a True Object Oriented Language whereas C++ supports both Object Oriented and Procedure Oriented paradigm.
2. Java does not support Operator Overloading whereas C++ supports it.
3. C++ contains Header Files whereas Java doesn’t contain header files.
4. Java supports Multi-Threading whereas C++ doesn’t support Multi-Threading.
5. Java does not support Pointers whereas C++ makes use of Pointers.
6. Java doesn’t supports Multiple Inheritance whereas C++ supports it.
4. Enlist Versions of Java.
1. Java Enterprise Edition(J2EE): Used to Develop Server-Side applications such as Java Servlets and Java Server Pages.
2. Java Micro Edition(J2ME): Used to develop applications for Mobile Devices such as Cell Phones, Tablets.
3. Java Standard Edition(J2SE): Develop Client Side Applets or Standalone Applications.
5. What is Object Oriented Programming Approach?
Object Oriented Programming is an approach that provides a way of modularizing programs by creating partitioned memory area for data as well as functions that can be used as templates for creating copies of such modules on demand. OOP allows decomposition of a problem into a number of entities called Objects and then builds data and functions around these objects.
6. Explain Vector Class in Java.
A Vector Class can be used to achieve a Generic Dynamic Array known as Vectors. Such Vector Class helps to store Objects of any quantity and Data Type. These Objects accessed into vector Class need not contain similar elements. Arrays are impemented as vectors. Vectors therefore, can be used to store a list of Objects that may differ in size.
7. What is jdb?
It is the Java Debugger. Jdb basically helps you out to find Java Bugs. It is a Command Line Debugger Tool for Java Classes. It provides inspection and debugging of Local and Remote Java Virtual Machine.
8. What is AppletViewer?
AppletViewer is a Java command line program to execute Java Applets. Its included in Java SDK. Java applet viewer helps to create Dynamic Applets as well as facilitates to view Java Applets.
9. What is an Object?
An Object is a Software Bundle of related State and Behaviour. Object is basically an instant of Class to which it belongs to. It is therefore possible to represent real world objects using Software Objects.
10. What is Inheritance?
Inheritance in Java is basically used by an Object to acquire the properties of another Object. Classes can therefore now be defined in terms of another previously defined Classes which thereby inherits the properties of previous Classes.
11. Enlist the Types of Errors in Java.
The Types of Errors in Java are as follows:
Compile Time Errors
This includes primarily Syntax Errors indicated by Java Compiler at Compile Time.
This includes primarily Syntax Errors indicated by Java Compiler at Compile Time.
Run Time Errors
This includes primarily the Logical Errors that are not catched by the Java Compiler by may result into Abnormal Termination of the Program. It includes Divide by Zero Error, Opening a File that doesn’t exist, etc.
This includes primarily the Logical Errors that are not catched by the Java Compiler by may result into Abnormal Termination of the Program. It includes Divide by Zero Error, Opening a File that doesn’t exist, etc.
12. What is InstanceOf Operator?
This operator is used to Reference Objects Variables. It tests if the first operand is an instance of its second. Its written as:
(Object Reference Variable) instanceOf (Class/ Interface Type)
13. Enlist Types of Constructors.
Types of Constructors are:
1. Default Constructor: This is a constructor without any parameters. A Default constructor is automatically created if you do not define any constructor for a Class.
2. Parameterized Constructor: A Constructor invoked with parameters is called a Parameterized constructor.
3. Overloading Constructor: Java allows Polymorphism i.e., a Method Overloading can be achieved by defining Two or more methods with the same name in a class.
14. Explain Static Methods.
Static methods in Java are used to create Methods or Functions that exists independent of Instances created for a Class. These methods doesn’t use any instance variables of any object of the class that they are defined in. Static methods can only access static data. They cannot call any other methods except Static Methods. Static Methods can not refer to This or Super Keywords.
15. Explain this Keyword.
There are times when a Function needs to refer to an Object that is invoked by it. This keyword facilitates reference to an Object within that particular methods. This keyword can be referenced to an object of current class type.
16. What is jar?
Jar stands for Java Archive. It is a utility that combines several files into a Single jar file or expand a jar file. It is basically an extended version of zip file.
17. Enlist Types of Inheritance.
Types of Inheritance supported in Java are as follows:
1. Single Inheritance
2. Hierarchical Inheritance
3. Multi-Level Inheritance
4. Multiple Inheritance
18. What is awt in Java?
AWT stands for Abstract Window Toolkit. It basically contains Widgets related to graphical User Interface designing that can be positioned using Layout Manager. AWT is platform independent. It provides Components, Containers and Layout Managers.
19. Explain Subclass constructor in Java.
A Subclass constructor is used to construct the instance variables of the Sub Class as well as the Super Class. A Sub Class can explicitly make a call to a Constructor of its very next Super Class. The Sub Class therefore, uses Super Keyword to invoke the Constructor methods of the Sub Class which results in execution of relevant constructor from Super Class based on the arguments passed to it.
20. What is the use of Final Keyword?
The value of a variable that has been declared as final cannot be changed later in the program. Java allows to declare a variable to be final irrespective of the Scope of the variable.
Final int variable = 15;
A Final local variable that has been declared but not initialised with any value is called as a Black Final.
21. Enlist come common Java Built-In API Packages.
The commonly used Packages in Java are as follows:
Java.lang: It includes support for Threads, Strings, Exceptions and much more.
java.util: Support for Date, Hash Tables, Vectors and others.
Java.io: Input and Output support for Classes.
Java.net: It provides support for Networking
Java.applet: Support for creation of Applets.
22. What is Polymorphism?
Polymorphism is used to allow routines or methods to execute different behaviour in different instances. An operator or a Function can be made to react differently in different positions. In C, we have Asterisk * that by default makes use of Polymorphism. It works as a Multiply Operator as well as a Pointer or a De-Reference Operator automatically.
23. Explain InputStream Class in Java.
An InputStream class is used to read 8-bit bytes that includes a Super Class known as InputStream and it also includes a number of Sub Classes that support Input related methods. It can perform actions like reading bytes, closing streams, marking positions in streams, skipping ahead in a stream and much more.
24. Explain Final Classes in Java.
A Class is declared as Final to avoid it from being Sub Classed. It therefore, helps to prevent the application of inheritance on that particular class. A Final Class is therefore a class that cannot be sub classed. If you try to extend the Classes from a Class declared as Final, a Compile Time Error will be generated.
25. What is javah?
javah is a utility to generate Source Files and Header Files required to implement Native Methods. These Header files are thus used for referencing an Object’s Instance variables from Native Source Codes.
26. Explain Methods Overloading in Java?
It is an application of Polymorphism. An overloaded method is the method that have the same name but number of arguments many differ or even the datatype may differ in some cases. Two methods that have the same name but different arguments or parameters within the same Class, it is known as Method overloading.
27. Enlist Features of Swing.
1. Customization and Other Features: Change Border, Align Text, Custom Cursors, Dockable Toolbars, etc.
2.Large Set of Controls: Text Areas To display HTML or RTF, Trees, Tabbed Panes, Toolbars, Image Buttons
3. Look and Feel: It can modify the look and feel of the GUI at Runtime and you can even customize Design.
4. Lightweight: It is not built on Native Windows Based System.
28. What is JDK?
JDK stands for Software Development Kit and it includes Tools such as JVM Compiler, Debugger, Interpreter and few others to develop Java Applets and Applications.
0 comments:
Post a Comment