Java Objects, Classes and Methods Interview Questions and Answers

Class and object - Class: A class is a program construct which encapsulates data and operations on data. In object oriented programming, the class can be viewed as a blue print of an object...
What is a method? - A java method is a set of statements to perform a task. A method is placed in a class...
Difference between instance variable and a class variable - An instance variable is a variable which has one copy per object / instance. That means every object will have one copy of it...
How to create instance of a class - Java supports 3 ways of creating instances...
Define an abstract class - A class with one of more abstract methods is called an Abstract class...
Abstract class and Interface - An abstract class can have both abstract and concrete methods whereas an interface can have only method signatures...
What is singleton class? - A class is defined as singleton class, if and only if it can create only one object...
What is a native method? - A native method is a method which is implemented in a non-java language that is targeted for a single machine type...
Difference between a public and a non-public class - A class with access specifier ‘public’ can be accessed across the packages...
Purpose of the Runtime class - The java runtime system can be accessed by the Runtime class...
Static and a non-static inner class - Like static methods and static members are defined in a class, a class can also be static...
Difference between the String and StringBuffer classes - String class is immutable. The characters of string objects can not be changed / modified...
What is the Dictionary class? - The Dictionary class is an abstract class. The class maps keys to values...
What is the ResourceBundle class? - A ResourceBundle is a group of related sub classes which are sharing the same base name...
What is the Vector class? - The capability of implementing a growable array of object is provided by the class Vector...
What is the SimpleTimeZone class? - SimpleTimeZone is a concrete subclass of TimeZone class...
Purpose of the System class - System class is provided with useful fields (static members) that are pertaining to the environment...
How are this() and super() used with constructors? - this() constructor is invoked within a method of a class, if the execution of the constructor is to be done before the functionality of that method...