Java Basic Definitions
Java Basic Definitions
1. Graphics Class
The Graphics class in Java is a part of the Abstract Window Toolkit (AWT) and is used to draw
graphics, such as lines, shapes, and text, on the screen. It provides methods for drawing,
painting, and manipulating graphics.
2. Animation
Animation in Java refers to the process of creating the illusion of movement by displaying a
sequence of images or graphics in rapid succession. Java provides several APIs, such as the
Graphics class and the Java 2D API, to create animations.
3. Exception
An exception in Java is an event that occurs during the execution of a program, such as an error
or an unexpected condition, that disrupts the normal flow of instructions. Exceptions can be
caught and handled using try-catch blocks.
4. Built-in Exception
Built-in exceptions in Java are predefined exceptions that are part of the Java language, such
as ArithmeticException, NullPointerException, and IOException. These exceptions are thrown
by the Java runtime environment when a specific error or condition occurs.
5. User-Defined Exception
A user-defined exception in Java is a custom exception class that is created by a programmer to
handle specific error conditions or exceptions that are not covered by built-in exceptions.
User-defined exceptions can be thrown and caught just like built-in exceptions.
6. Thread
A thread in Java is a separate flow of execution that can run concurrently with other threads.
Threads are lightweight processes that share the same memory space and resources, allowing
for efficient and concurrent execution of tasks.
7. Multithread
Multithreading in Java refers to the ability of a program to execute multiple threads concurrently,
improving responsiveness, efficiency, and throughput. Multithreading is achieved using the
Thread class or the Runnable interface.
8. Applet
An applet in Java is a small program that runs within a web browser, typically used to provide
interactive content, such as games, animations, or multimedia presentations. Applets are written
in Java and are executed by the Java Virtual Machine (JVM) within the browser.
10. Frames
A frame in Java is a top-level window that can contain other GUI components, such as buttons,
labels, and text fields. Frames are created using the Frame class and can be used to create
standalone GUI applications or applets. Frames can be customized with various attributes, such
as title, size, and layout.
1. Method Overloading
Method overloading in Java is a feature that allows multiple methods with the same name to be
defined, but with different parameter lists. The method that gets called is determined by the
number and types of arguments passed to it.
2. Constructor
A constructor in Java is a special method that is used to initialize objects when they are created.
Constructors have the same name as the class and do not have a return type.
3. Constructor Overloading
Constructor overloading in Java is a feature that allows multiple constructors with the same
name to be defined, but with different parameter lists. The constructor that gets called is
determined by the number and types of arguments passed to it.
4. Inheritance
Inheritance in Java is a mechanism that allows one class to inherit the properties and behavior
of another class. The inheriting class is called the subclass, and the class being inherited from is
called the superclass.
5. Single Inheritance
Single inheritance in Java is a type of inheritance where a subclass inherits from only one
superclass.
6. Multilevel Inheritance
Multilevel inheritance in Java is a type of inheritance where a subclass inherits from a
superclass, and the superclass also inherits from another superclass.
7. Hierarchical Inheritance
Hierarchical inheritance in Java is a type of inheritance where multiple subclasses inherit from
the same superclass.
8. Multiple Inheritance
Multiple inheritance in Java is not supported directly, but it can be achieved using interfaces.
Multiple inheritance is a type of inheritance where a subclass inherits from multiple
superclasses.
9. Class
A class in Java is a blueprint or template that defines the properties and behavior of an object.
10. Object
An object in Java is an instance of a class, and it has its own set of attributes (data) and
methods (functions).
11. Variable
A variable in Java is a named storage location that holds a value.
12. Package
A package in Java is a collection of related classes and interfaces.
13. Interface
An interface in Java is a abstract class that defines a set of methods that must be implemented
by any class that implements it.
16. String
A String in Java is a sequence of characters.
17. StringBuffer
A StringBuffer in Java is a mutable sequence of characters.
18. Methods
Methods in Java are blocks of code that perform a specific task.
19. Recursion
Recursion in Java is a programming technique where a method calls itself repeatedly until it
reaches a base case.
24. Layout
A layout in Java is a way of arranging components in a GUI.
26. Label
A label in Java is a GUI component that displays text.
27. TextField
A text field in Java is a GUI component that allows the user to enter text.
28. TextArea
A text area in Java is a GUI component that allows the user to enter multiple lines of text.
29. CheckBox
A check box in Java is a GUI component that allows the user to select or deselect an option.
30. CheckBoxGroup
A check box group in Java is a group of check boxes that can be selected or deselected
together.
31. Button
A button in Java is a GUI component that can be clicked to perform an action.
32. List
A list in Java is a GUI component that displays a list of items.
33. Choice
A choice in Java is a GUI component that allows the user to select one item from a list of items.
2. Multidimensional Array
A multidimensional array in Java is an array that contains one or more arrays as its elements.
Multidimensional arrays are used to represent complex data structures such as matrices and
tables.
3. Bytecode
Bytecode in Java is the intermediate code generated by the Java compiler (javac) when it
compiles Java source code (.java files) into an executable format. Bytecode is
platform-independent and can be executed by any Java Virtual Machine (JVM).
5. Applet
An applet in Java is a small program that runs within a web browser. Applets are used to
provide interactive content, such as games, animations, and multimedia presentations, on web
pages.
6. Applet Methods
Applet methods are special methods in Java that are used to control the execution of an applet.
The most common applet methods are:
7. Thread Priorities
Thread priorities in Java are used to determine the order in which threads are executed by the
JVM. Threads with higher priorities are executed before threads with lower priorities. There are
three types of thread priorities in Java:
- `Thread.MIN_PRIORITY`
- `Thread.NORM_PRIORITY`
- `Thread.MAX_PRIORITY`
You can set the priority of a thread using the `setPriority()` method, passing one of these values
or a custom value between 1 and 10:
```
Thread thread = new Thread();
thread.setPriority(Thread.NORM_PRIORITY);
```