Java Program Ans 5 Sem
Java Program Ans 5 Sem
In Java, the this keyword refers to the current instance of a class. It is used to
refer to the current object within an instance method or constructor.
Classes
Interfaces
Arrays
d) What is an Interface?
container.setLayout(new LayoutManager());
Access Controls:
· Naming Rules:
L) Define Inheritance.
Array:
o Fixed size.
o Can store elements of the same type.
ArrayList:
o Dynamic size.
o Can store elements of any type (if using generics).
o Provides more functionality with methods like add(), remove(),
etc.
Types:
1. Compilation Errors: Occur when there are issues in the source code
(e.g., syntax errors).
2. Runtime Errors: Occur during program execution (e.g., exceptions like
NullPointerException).
3. Logical Errors: The program runs but produces incorrect results due
to flaws in logic.
An abstract class is a class that cannot be instantiated on its own and may
contain abstract methods (methods without implementation). Subclasses are
required to implement abstract methods.
x) What is Container?
c) Define Keyword-Static.
The static keyword in Java is used to indicate that a particular field, method,
or inner class belongs to the class itself rather than instances of the class. A
static member is shared by all instances of the class. Example:
d) Why do we set the environment variable in Java?
Inheritance allows:
g) What is Swing?
Swing is a GUI (Graphical User Interface) toolkit in Java for building desktop
applications. It is part of the Java Foundation Classes (JFC) and provides a
rich set of GUI components, such as buttons, text fields, and tables, for
building interactive applications.
q) Define polymorphism.