Java VIVA Questions

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

1.

Java vs C++

Java is platform independent language (I.e It runs on any Operating system.)


Other programming language does not support this.

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.

3. Method overriding and method overloading


Method overloading means the class may have many functions with the same name but
different arguments.
Method overriding means classes may have may many functions with the same name and
with the same arguments in different levels of classes(base class and sub-class).
4. Class and object
Class is the collection of data members and functions.
An object is an instance of the class.

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.

12. Applet vs swing


Applets are intended to be small bits of functionality run in a web browser and
downloaded on-demand. Swing is a collection of user interface components, like text
boxes and windows, that are meant to be assembled by a developer for use on the
desktop.

You might also like