Java Final Exam Notes
1. Explain the Project's Folder Structure
Understand where to store and find specific files in a Java project:
- **pom.xml**: Contains project configurations, dependencies, and plugins for Maven
projects.
- **.gitignore**: Specifies files and directories to exclude from version control.
- **src/main/java/../controller**: Contains classes responsible for handling requests and
directing application flow.
- **src/main/java/../model**: Stores classes representing the application's data structure
or logic.
- **src/main/java/shared**: Holds shared utilities or helper classes used across the project.
- **src/main/resources**: Keeps non-code resources like configuration files and templates.
- **src/main/webapp**: Contains the frontend resources such as HTML, CSS, JavaScript, and
JSP files.
- **src/main/webapp/WEB-INF**: Stores configuration files and server-side components
like web.xml.
- **src/test**: Holds test classes to ensure code reliability.
2. Demonstrate the Use of Collection Classes and Methods
Java Collections Framework provides reusable data structures:
- **Collections**: Utility class with static methods for operations like sorting and searching.
- **List**: An ordered collection allowing duplicates (e.g., ArrayList).
- **ArrayList**: Resizable array implementation of List.
- **Set**: A collection that does not allow duplicate elements.
- **HashSet**: A hash table-based implementation of Set.
3. Create and Use Threads
Steps to work with Threads:
- **Runnable**: Implement to define the task.
- **Thread**: Instantiate and start the thread.
- **synchronized keyword**: Ensures thread-safe access to resources.
4. Connect to and Query Databases
Classes and methods needed:
- **Connection**: Establishes a database connection.
- **AutoCloseable and try-with-resources**: Ensures connections are closed automatically.
- **CallableStatement**: Executes stored procedures using parameter indexes.
- **ResultSet**: Retrieves query results.
5. Streams and Sockets
For communication with files and sockets:
- **ServerEndpoint**: Requires JSON, Encoder, and Decoder for WebSocket communication.
- **JavaScript WebSocket**: Communicates with the server via WebSockets.
6. Get and Loop Through HTML Content
Diagrams for clarity:
- **Class Diagrams**: Show class relationships.
- **ER Diagrams**: Represent database entities and relationships.
- **Sequence Diagrams**: Illustrate object interactions over time.
7. Validation and Error Handling
Key concepts:
- **Validator Methods**: Ensure data validity.
- **Regular Expressions**: Validate text formats.
- **Setter Methods**: Apply validation.
- **getParameter and setAttribute**: Handle request data and share attributes.
- Display concise error and success messages.
8. Intellectual Property
Important points:
- **Copyright Length**: Individuals (life + 70 years), corporations (95 years from
publication or 120 years from creation).
- **Licenses**:
- MIT: Open and permissive.
- GNU: Requires derived works to be open-source.
- Commercial: Restricted use.
- **Fair Use**: Limited use of copyrighted material.
- **Work for Hire**: Ownership belongs to the employer.
- **Non-Compete Clause**: Prevents competition with an employer after leaving.
9. Contributing to Open Source Projects
Steps to contribute on GitHub:
- **Forking**: Create a personal copy of a repository.
- **Cloning**: Download the repository to work locally.
- **Branching**: Develop new features without affecting the main branch.
- **Pull Requests**: Propose changes to the original repository.
10. APIs
Working with APIs:
- Get API keys from websites offering APIs (e.g., weather, finance, maps).
- Integrate APIs into projects for additional functionality.