Java VIVA Questions
Java VIVA Questions
Java VIVA Questions
Java vs C++
2. Packages
A java package is a group of similar types of classes, interfaces, and sub-packages.
there are two types of packages: built-in packages and user-defined packages.
Many in-built packages are available in Java, including java.util, java.lang, java.awt,
java.net, java.io, java.sql, etc.
5. Access Specifier
Public – Data can be accessed by all the classes
Private – Data can be accessed by the same class only
Protected – Data can be accessed by the same class and its subclasses
Default – Data can be accessed within the package
6. Inheritance
Process of creating the new class ( sub class ) by using an already existing class (Base
class).subclasses uses the properties of base classes.
Adv: No need to write code again and saves the memory (ReUsabilty).
Types:
Single Inheritance
Multilevel inheritance
Hierarchy inheritance
Hybrid Inheritance
7. Interface
It is also like class. It has static data members and method declarations (abstract functions).
It is used to implement the multiple interface in java.
8. Constructor
A constructor in Java is a special method that is used to initialize objects.
The constructor is called when an object of a class is created. Consructor name should
be same as class name.
9. String
String is collection of characters.
Predefined string functions in java.
-length()
-equal()
-toUpperCase()
-toLowerCase()
-isEmpty()
-concat() etc..
10. Applet
Applet is a special type of program that is embedded in the webpage to generate the
dynamic content. It runs inside the browser and works at client side.
11. Thread
Thread is often referred to as a lightweight process. The process can be split down into so
many small sub problems(threads).
Advanarges:
Running all the threads simultaneously. It is also called mmutithreading. It uses the CPU
effectively and work can be completed quickly.