java2marks
java2marks
A: JDK (Java Development Kit) is a software development kit used to develop Java
applications. It includes the JRE (Java Runtime Environment), an interpreter/loader (Java), a
compiler (Javac), an archiver (Jar), a documentation generator (Javadoc), and other tools
needed for Java development. To build a Java program, write the source code in a file with a
.java extension, compile it using the javac command, and run the compiled bytecode with
the java command. For example:
1. Write code in HelloWorld.java.
2. Compile: javac HelloWorld.java.
3. Run: java HelloWorld.
j) Define polymorphism.
A: Polymorphism in Java is the ability of a single interface to support multiple underlying
forms (data types). It allows methods to perform differently based on the object they are
acting upon, commonly implemented through method overloading and overriding.
void accelerate() {
speed += 10;
}
}
g) What is Swing?
A: Swing is a part of Java Foundation Classes (JFC) used to create window-based
applications. It provides a rich set of GUI components, such as buttons, text fields, and tables,
that can be used to create complex user interfaces.
j) What is a Panel?
A: A Panel is a container component in AWT (Abstract Window Toolkit) that can hold a
group of components inside it. It is used for organizing components within a window and acts
as a generic container.
3
A: Inheritance is an object-oriented programming concept where a new class (subclass)
inherits properties and behaviors (fields and methods) from an existing class (superclass). It
allows for code reusability and establishes a natural hierarchy between classes.
x) What is a Container?
A: A Container is a component in AWT or Swing that can hold and manage other
components. Examples include Panel, Frame, and JPanel.
4
A: The this keyword in Java is a reference variable that refers to the current object. It is
used to avoid confusion between class attributes and parameters with the same name, to
invoke current class methods, or to pass the current object as a parameter.
d) What is an Interface?
A: An interface in Java is a reference type, similar to a class, that can contain only abstract
methods (method signatures without implementations) and static constants. It is used to
specify a set of methods that a class must implement, promoting multiple inheritance and
abstraction.