Java-Lab Viva
Java-Lab Viva
What is Java?
Java is an object oriented programming language
What is JVM?
Java Virtual Machine which accepts java byte code and produces result
What is class?
Class is blue print for objects; Class is collection of objects; Class gives the general
structure for objects.
What is object?
Object is an instance of class. Object is real world entity which has state, identity and
behavior.
What is encapsulation?
Encapsulation is packing of data with their methods
What is abstraction?
Abstraction is the process of identification of essential features of objects
What is hierarchy?
Ordering of classes (or inheritance)
What is inheritance?
Extending an existing class is called inheritance. Extracting the features of super class
What is interface?
Interface is collection of final variables and abstract methods
(We need not give final and abstract keywords and By default they are public methods)
What is polymorphism?
Multiple (poly) forms (morphs)
Same instance can respond different manners is called polymorphism
Can we achieve run time polymorphism in Java?
Yes, also called as dynamic polymorphism. Possible by dynamic method dispatch
What is overloading?
Same method name can be used with different type and number of arguments (in same
class)
What is overriding?
Same method name, similar arguments and same number of arguments can be
defined in super class and sub class. Sub class methods override the super class methods.
Keywords section
What is keyword?
Java reserved word which should is not used as variable/class-name (e.g.: break, for, if,
while etc)
What is this( )?
Used for calling another constructor of current class
What is super keyword?
To call super class variables and super class methods we can use super key word
What is super( )?
Used for calling of super class constructor and it should be first executable statement in
sub class constructor
What is package?
Package is collection of classes and interfaces
What is CLASSPATH?
It is an environment variable which is used for defining the location of class files
What is jar?
Jar stands for Java archive files, compressed set of class files and can be used in
CLASSPATH
What is the meaning of import java.awt.*;?
Import all the classes and interfaces in the java.awt.package. This doesn't imports other
packages
defined in java.awt. package.
What is exception?
Abnormal termination of program is called exception