Java Interview Questions and Answers - Part 2

Java - difference between Java and JavaScript - Java is an Object Oriented Programming Language which is developed by Sun Microsystems. It is capable of running on multiple operating systems with the help of.....
Java - performance profile in Java - To improve the performance of a program, performance analysis is used. The usual purpose of this analysis is to determine which sections of a program to optimize......
Java runs mostly on all platforms. For running a Java program we need JVM on all the platforms. If JVM is not installed on any platform than we are not able to run ...
To access native operating system calls from my Java program JNI is used. Java native Interface (JNI) is a programming framework that allows Java code...
A socket is a software endpoint that establishes communication between a server program and one or more client programs...
There are two methods of sending data from Java program to a CGI Program: a.) The first method is that we can use CGI scripting on both client and server by using...
Java - purpose of the executable files - java_g is a non-optimized version of java suitable for use with debuggers like jdb. When using java_g to run a program that loads a shared library...
URLConnection is a class under java.net package. The abstract class URLConnection is the superclass of all classes that represent...
The standard input stream is represented by the InputStream object System.in. For reading a whole line at a time BufferedReader is chained to an InputStreamReader...
Threads share the same memory space, i.e., they can share resources. However, there are critical situations where it is desirable that only one thread...
A thread in Java is represented by an object of the Thread class. Implementing threads is achieved in one of two ways:...
A listener’s class has to implement Listener interface which means all the methods of the interface must be defined in the class...
The Component class is found under java.awt package. The container class is the subclass of Component class...
Runtime Exceptions like out-of-bound array indices, NullPointerException , AirthmeticException are all subclasses of java.lang.RuntimeException class...
Stateless Session Bean Lifecycle: The stateless session bean does not become passive, so its life cycle has two stages:...
Activation is a process of associating an instance with EJB object. Activating a bean is the process of restoring a stateful bean instance’s state relative to its EJB...
JSP caching lets you cache tag invocation results within the Java engine. Each can be cached using different cache criteria. JSP caching is defined by following:..
Authentication options available in Servlets: There are four different options for authentication in servlets...
Java Beans are reusable components. They are used to separate Business Logic from Presentation Logic. Internally a bean is just an instance of a class...
A Java Bean is a reusable software component that can be visually manipulated in builder tools. They can’t manipulate JSP content...
The scope of JSP objects is divided into four parts. They are: 1. Page: Page scope means the object can be accessed within the page only on which it is created...
Externalization is same as serialization. It extends Serializable interface. To externalize your object, you need to implement Externalizable interface that extends ...
For a primitive data types, a value narrower data type can be converted to a value of a broader data type without loss of information...
Deep cloning makes a distinct copy of each of object’s field. By this the two objects are not dependent on each other...
Java features - Simple, Object-Oriented, Robust, Distributed, Portable, Interpreted, Multithreaded, Platform Independent, Secure...
Java program execution - What is JVM? Explain its roles and functions, Why Java is called as Platform independent language. How Java executable executes on any platform where JVM is available...
Java architecture - Java programming language, Java class file format, Java Application Programming Interface, Java virtual machine...
Java class - features of Java class, What are accessors and mutator methods in a Java class?, Explain the importance of 'this' reference. Write a code to depicts the use of 'this' reference...
Java constructors - What is a constructor? Explain the differences between methods and constructor, Differences between constructors and methods, Write code to depict the use of constructor...
Java class member - What is instance members?, What is instance variable?, What is instance method?, What is static member?, What is static variable?...
Java packages - What are Java packages? Explain the importance of Java packages., Steps for creating a package in Java, Explain the packages access specifier, i.e. private, protected, public, default...
Java garbage collector - Explain Java Garbage collector. Why garbage collection? Brief explanation of Garbage collection algorithms., Explain the importance of finalizers in Java...
Importance of 'super' keyword in Java - The keyword ‘super’ is used for referring parent class instance...
Java method overloading and overriding - Define Method overloading, Uses of method overloading, uses of method overriding, Difference between overloading and overriding...
Java string class - Describe Java string class. Explain methods of Java string class. Explain the characteristics of StringBuffer class.....
Java inner classes - What is Java inner class? Explain the types of inner classes, i.e. Static member classes, Member classes, Local classes, Anonymous classes, Functionality of wrapper classes. List the primitive types and the corresponding wrapper classes...
Java reflection class - Explain about Java reflection class - Classes, interfaces, methods, instance variables can be inspected at runtime by using reflection class...
Java swing - What is Swing? Explain the need of Swing, features of Swing, Java Swing class hierarchy, need of Layout manager...
Java layout manager - Different layout manager in Java - Border Layout, Flow Layout, Card Layout, Grid Layout, Grid Bag Layout,...
Java exception handling - Explain the need of Exception handling, Exceptions categories, i.e. checked and unchecked exceptions, Provide the general form of Exception handling constructs with explanation, What is user defined Exception?,...
Java multithreading - What is Multithreading? Explain the life cycle of a thread, Explain how to use thread class for Multithreading in Java, What are the methods of thread class in java?, Can your explain thread priorities?...
Java file handling - Use of Streams, Difference between Stream classes and Reader writer classes, Explain and demonstrate the use of File, RandomAccessFile classes, Explain the use of Reader and Writer classes...
Java utility classes - What is object Serialization? Explain the use of Persisting object, step of using object Deserialization...
Java socket programming - What is socket? Explain the features of socket, characteristics of Java socket class, InetAddress class, DatagramSocket class, DatagramPacket class...
JDBC - Purposes of JDBC API, Describe 4 types of JDBC drivers and their characteristics with usages, State the functionalities of important classes in JDBC packages, Explain how to use JDBC statement to execute SQL queries...
The == operator compares references and not contents. It compares two objects and if they are the same object in memory and present in the same memory location...
Static variables are declared with the static keyword in a class, Static variables are always called by the class name...
The purpose of garbage collection is to identify and remove objects that are no longer needed by a program...
Abstract class can have a constructor. But as we can't instantiate abstract class, we can't access it through the object...
Addressing Portability: Many computers of different types with several operating systems are connected to network / internet...
The integer and floating-point types are different in terms of the consumption of the bits which represent them...
Endianness is the process of ordering the addressable sub units such as words, bytes or bits in a longer word that is to store in an external memory...
To enable a computer system for storing text and numbers which is understandable by humans, there should be a code that transforms characters into numbers. ...
A loop is a set of statements that is supposed to repeat one or more times. Java supports 3 loops...
The key word ‘new’ is used for creation of objects. Primitive types are to use constants but not objects. Hence, new key word is not used for primitive variables...
The finalize() method of java is invoked by JVM to reclaim the inaccessible memory location, When the ‘orphan’ object (without reference) is to be released, JVM invokes the finalize() method...
The equals() method is defined in String class in order to test whether two strings values are same sequence of characters...
A string object that is created using “String” class is immutable. The characters of the object can not be changed / modified. There are some methods, such as split(), substring(), beginsWith() etc...