paper 3 java
paper 3 java
Define interface?
An interface is a blueprint for a class. It is used to define a set of methods that a class
must implement, but it does not provide any implementation for those methods.
Key Points:
Syntax:
container.setLayout(LayoutManager layout);
Flowlayout
Gridlayout
Borderlayout
Frame (JFrame)
Panel (JPanel)
Access Modifiers:
Byte Streams
Purpose: Used to handle raw binary data (8-bit byte data). They are suitable for reading and
writing all types of I/O, such as image files, audio files, etc.
Classes: These are based on InputStream and OutputStream classes.
2. Character Streams
Purpose: Used to handle characters (16-bit Unicode data). They are suitable for reading and
writing text files (e.g., .txt, .csv, etc.) with proper encoding and decoding.
Classes: These are based on Reader and Writer classes.
In Java, the Collection Framework provides a set of classes and interfaces to store and
manipulate groups of data. It is part of the `java.util` package and includes the
following main components:
1. Interfaces:
- List: An ordered collection (also known as a sequence). It allows duplicate
elements and provides positional access (e.g., `ArrayList`, `LinkedList`).
- Set: A collection that doesn't allow duplicate elements (e.g., `HashSet`,
`LinkedHashSet`).
2. Classes:
- ArrayList: A dynamic array that grows as needed. It implements the List interface
and allows random access.
- LinkedList: A doubly linked list that implements both List and Deque interfaces,
allowing more efficient insertions and deletions.
Finalize Keywoard
· The finalize method is called by the garbage collector before deleting an object.
· It is used to clean up resources like files or database connections.
· The garbage collector calls finalize when the object is no longer needed.
Example:
class MyClass {
System.gc();