Unit-2 2 Marks
Unit-2 2 Marks
An abstract class is, conceptually, a class that cannot be instantiated and is usually implemented
as a class that has one or more pure virtual (abstract) functions.
A pure virtual function is one which must be overridden by any concrete (i.e., non-abstract)
derived class. This is indicated in the declaration with the syntax " = 0" in the member function's
declaration.
3) How dynamic initialization variables are achieved in java?(AU NOV-DEC-2012)
Utility methods
Declaring Interfaces:
The interface keyword is used to declare an interface. Here is a simple example to declare an
interface:
Example:
/* File name : NameOfInterface.java */
import java.lang.*;
//Any number of import statements
Class is a template for a set of objects that share a common structure and a common
behaviour.
Abstraction defines the essential characteristics of an object that distinguish it from all other
kinds of objects. Abstraction provides crisply-defined conceptual boundaries relative to the
perspective of the viewer. Its the process of focussing on the essential characteristics of an
object. Abstraction is one of the fundamental elements of the object model.
The Object class is the highest-level class in the Java class hierarchy. The Class class is used to
represent the classes and interfaces that are loaded by a Java program. The Class class is used to
obtain information about an object's design. A Class is only a definition or prototype of real life
object. Whereas an object is an instance or living representation of real life object. Every object
belongs to a class and every class contains one or more related objects.
27) What is the difference between a static and a non-static inner class?
A non-static inner class may have object instances that are associated with instances of
the class's outer class. A static inner class does not have any object instances.
28) What is the difference between abstract class and interface?
a) All the methods declared inside an interface are abstract whereas abstract class must
have at least one abstract method and others may be concrete or abstract.
b) In abstract class, key word abstract must be used for the methods whereas interface we need
not use that keyword for the methods.
c) Abstract class must have subclasses whereas interface can’t have subclasses.
29) Can you have an inner class inside a method and what variables can you access?
Yes, we can have an inner class inside a method and final variables can be accessed.
33) What is a cloneable interface and how many methods does it contain?
It is not having any method because it is a TAGGED or MARKER interface.
The Object class provides five methods that are critical when writing multithreaded Java
programs:
notify
notifyAll
wait (three versions)