A class is nothing but a blueprint or a template for
creating different objects which defines its properties and behaviours. Java
class objects exhibit the properties and behaviours defined by its class. A class can
contain fields and methods to describe the behaviour of an object. A class is
nothing but a blueprint or a template for creating different objects which
defines its properties and behaviours. Java class objects exhibit the properties and behaviours
defined by its class. A class can contain fields and methods to describe
the behaviour of an object.
class
Sample {
public
static void main(String[] args) {
System.out.println(“I am from Class Main
Method”);
}
}
_________________________________________________________________________________
|
Define
class and object. Explain them with an example using java
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? Provide several signatures of the methods
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
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...
|
|
Explain how
to create instance of a class by giving an example
How
to create instance of a class - Java supports 3 ways of creating instances...
|
|
Define an
abstract class. Explain its purpose
Define
an abstract class - A class with one of more abstract methods is called an
Abstract class...
|
|
What is the
difference between an Abstract class and Interface?
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? Where is it used?
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?
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
Difference
between a public and a non-public class - A class with access specifier
‘public’ can be accessed across the packages...
|
|
What is the
purpose of the Runtime class?
Purpose
of the Runtime class - The java runtime system can be accessed by the Runtime
class...
|
|
What is the
difference between a static and a non-static inner 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
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?
What
is the Dictionary class? - The Dictionary class is an abstract class. The
class maps keys to values...
|
|
What is the
ResourceBundle class?
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?
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?
What
is the SimpleTimeZone class? - SimpleTimeZone is a concrete subclass of
TimeZone class...
|
|
What is the
purpose of the System 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?
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...
|