100 Java Exam Key Knowledge Points | Generated by AI
Question: What are 100 essential knowledge points for the 08553 Introduction to Programming—Java exam in the China National Higher Education Self-study Examination?
Answer: The 08553 Introduction to Programming—Java exam focuses on the fundamentals of the Java language, Object-Oriented Programming (OOP) principles, and basic GUI/IO operations. Below are 100 key knowledge points organized by category to help you prepare.
I. Java Basics & Environment
- Java’s Origin: Created by Sun Microsystems (led by James Gosling) in 1995.
- Platform Independence: Achieved via the “Write Once, Run Anywhere” (WORA) principle.
- JVM (Java Virtual Machine): The engine that interprets and executes Java bytecode.
- JRE (Java Runtime Environment): Includes the JVM and core libraries needed to run programs.
- JDK (Java Development Kit): Includes JRE plus development tools like
javac(compiler). - Bytecode: The
.classfile generated by the compiler; it is intermediate code between source and machine code. - Compilation Command:
javac FileName.java. - Execution Command:
java ClassName. - Main Method Signature:
public static void main(String[] args). - Source File Rule: A
.javafile can have only onepublicclass, and the filename must match that class name. - Comments: Single-line (
//), multi-line (/* ... */), and documentation (/** ... */). - Case Sensitivity: Java is strictly case-sensitive (e.g.,
Mainandmainare different). - Keywords: Reserved words (like
class,int,void) cannot be used as identifiers.
II. Data Types, Variables, and Operators
- 8 Primitive Types:
byte,short,int,long,float,double,char,boolean. - Integer Sizes:
byte(8-bit),short(16-bit),int(32-bit),long(64-bit). - Floating Point:
float(32-bit),double(64-bit). Default literal isdouble. - Char Type: Uses 16-bit Unicode; can represent Chinese characters.
- Boolean Type: Only two values:
trueorfalse(cannot be 0 or 1). - Type Casting (Implicit): Automatic conversion from smaller to larger types (e.g.,
inttodouble). - Type Casting (Explicit): Manual conversion (e.g.,
(int)3.14). - Arithmetic Operators:
+,-,*,/,%(modulus). - Relational Operators:
==,!=,>,<,>=,<=. - Logical Operators:
&&(AND),||(OR),!(NOT). - Short-circuiting:
&&and||stop evaluating if the result is determined early. - Assignment Operators:
=,+=,-=, etc. - Increment/Decrement:
++i(pre-increment) vsi++(post-increment).
III. Control Structures
- if-else: Basic conditional branching.
- switch-case: Works with
byte,short,char,int,String(since Java 7), and Enums. - break in switch: Prevents “fall-through” to the next case.
- while loop: Condition checked before execution.
- do-while loop: Condition checked after execution (runs at least once).
- for loop: Best for known iteration counts.
- Enhanced for loop:
for (Type var : collection)used for arrays and collections. - break: Exits the current loop entirely.
- continue: Skips the rest of the current iteration and moves to the next.
IV. Array Handling
- Array Definition: Fixed-size container for elements of the same type.
- Index: Starts at
0and ends atlength - 1. - Initialization:
int[] arr = new int[5];orint[] arr = {1, 2, 3};. - Length Property:
arr.lengthreturns the number of elements. - Exception: Accessing
arr[length]triggersArrayIndexOutOfBoundsException. - Multi-dimensional Arrays: An array of arrays (e.g.,
int[][] matrix).
V. Object-Oriented Programming (OOP) Core
- Class: A blueprint or template for objects.
- Object: An instance of a class.
- Encapsulation: Bundling data (fields) and methods; using
privatefor data hiding. - Inheritance: Using
extendsto inherit properties from a parent class. - Polymorphism: The ability of an object to take on many forms (Overloading vs Overriding).
- Abstraction: Using
abstractclasses andinterfacesto define “what” rather than “how.” - Constructor: A special method to initialize objects; has no return type and matches the class name.
- Default Constructor: Provided by Java automatically if no constructor is defined.
- this keyword: Refers to the current object instance.
- super keyword: Refers to the parent class instance or constructor.
- Method Overloading: Same name, different parameters (same class).
- Method Overriding: Same name and parameters in a subclass (using
@Override). - Access Modifiers:
public,protected,default(no modifier), andprivate. - private: Visible only within the same class.
- public: Visible everywhere.
- protected: Visible in the same package and subclasses.
- final (variable): Constant value.
- final (method): Cannot be overridden.
- final (class): Cannot be inherited (e.g.,
Stringclass). - static (field): Shared by all instances of the class.
- static (method): Belongs to the class, not an object; cannot access non-static members.
VI. Interfaces and Abstract Classes
- Abstract Class: Cannot be instantiated; can have abstract and concrete methods.
- Interface: A contract; only contains constants and abstract methods (pre-Java 8).
- Multiple Inheritance: A class can implement multiple interfaces but extend only one class.
- implements keyword: Used to use an interface.
VII. String Handling
- String: Immutable (value cannot change after creation).
- StringBuffer: Mutable, thread-safe (synchronized).
- StringBuilder: Mutable, faster, but not thread-safe.
- String Comparison: Always use
.equals()for content, not==(which compares memory address). - Common Methods:
length(),charAt(),substring(),indexOf(),trim().
VIII. Exception Handling
- Throwable: The root class of all errors and exceptions.
- Error: Serious problems (e.g.,
OutOfMemoryError) that programs shouldn’t try to catch. - Exception: Divided into Checked and Unchecked.
- Checked Exceptions: Checked at compile time (e.g.,
IOException). Must usetry-catchorthrows. - Unchecked (Runtime) Exceptions: Occur at runtime (e.g.,
NullPointerException). - try block: Contains code that might throw an exception.
- catch block: Handles the exception.
- finally block: Code that always runs, regardless of an exception (used for closing resources).
- throw: Used to manually trigger an exception.
- throws: Declared in a method signature to indicate it might throw an exception.
IX. Java I/O System
- Stream: A sequence of data.
- Byte Streams:
InputStream,OutputStream(for images, binary files). - Character Streams:
Reader,Writer(for text files). - File Class: Used to manipulate file properties and directories.
- Buffered Streams: Improve performance by reducing the number of I/O operations.
- Serialization: Converting an object into a byte stream using the
Serializableinterface.
X. GUI & Event Handling (AWT/Swing)
- AWT (Abstract Window Toolkit): Heavyweight, platform-dependent components.
- Swing: Lightweight, platform-independent components (starts with ‘J’, e.g.,
JButton). - JFrame: The main window of a GUI application.
- Layout Managers:
FlowLayout,BorderLayout,GridLayout. - Event Source: The component that generates the event (e.g., a Button).
- Event Listener: An interface that handles the event (e.g.,
ActionListener). - Event Handler: The method inside the listener (e.g.,
actionPerformed).
XI. Multithreading & Collections
- Thread Creation: Extend
Threadclass or implementRunnableinterface. - Thread Start: Call the
.start()method, which invokes.run(). - Synchronization: Using the
synchronizedkeyword to prevent data races. - Collection Interface: Root of the collection hierarchy (List, Set).
- ArrayList: Dynamic array, allows duplicates, maintains order.
- HashMap: Stores key-value pairs; no duplicate keys allowed.
Would you like me to provide a practice code snippet for any of these specific topics, such as inheritance or exception handling?