# java-basics
**Repository Path**: codes_test/java-basics
## Basic Information
- **Project Name**: java-basics
- **Description**: No description available
- **Primary Language**: Unknown
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2025-02-27
- **Last Updated**: 2025-02-27
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# Java Basics
> *Click ★ if you like the project. Your contributions are heartily ♡ welcome.*
## Related Topics
* *[Multithreading](multithreading-questions.md)*
* *[Collections](collections-questions.md)*
* *[Java Database Connectivity (JDBC)](JDBC-questions.md)*
* *[Java Programs](java-programs.md)*
* *[Java String Methods](java-string-methods.md)*
* *[Jakarta Server Pages (JSP)](jsp-questions.md)*
* *[Servlets](servlets-questions.md)*
* *[Java Multiple Choice Questions](java-multiple-choice-questions-answers.md)*
* *[Java Design Pattern](https://github.com/learning-zone/java-design-patterns)*
* *[Hibernate](https://github.com/learning-zone/hibernate-basics)*
* *[Spring Framework Basics](https://github.com/learning-zone/spring-basics)*
## Table of Contents
* [Introduction](#-1-introduction)
* [Java Architecture](#-2-java-architecture)
* [Java Data Types](#-3-java-data-types)
* [Java Methods](#-4-java-methods)
* [Java Functional programming](#-5-java-functional-programming)
* [Java Lambda expressions](#-6-java-lambda-expressions)
* [Java Classes](#-7-java-classes)
* [Java Constructors](#-8-java-constructors)
* [Java Array](#-9-java-array)
* [Java Strings](#-10-java-strings)
* [Java Reflection](#-11-java-reflection)
* [Java Streams](#-12-java-streams)
* [Java Regular Expressions](#-13-java-regular-expressions)
* [Java File Handling](#-14-java-file-handling)
* [Java Exceptions](#-15-java-exceptions)
* [Java Inheritance](#-16-java-inheritance)
* [Java Method Overriding](#-17-java-method-overriding)
* [Java Polymorphism](#-18-java-polymorphism)
* [Java Abstraction](#-19-java-abstraction)
* [Java Interfaces](#-20-java-interfaces)
* [Java Encapsulation](#-21-java-encapsulation)
* [Java Generics](#-22-java-generics)
* [Miscellaneous](#-23-miscellaneous)
## # 1. INTRODUCTION
## Q. What are the important features of Java 8 release?
* Interface methods by default;
* Lambda expressions;
* Functional interfaces;
* References to methods and constructors;
* Repeatable annotations
* Annotations on data types;
* Reflection for method parameters;
* Stream API for working with collections;
* Parallel sorting of arrays;
* New API for working with dates and times;
* New JavaScript Nashorn Engine ;
* Added several new classes for thread safe operation;
* Added a new API for `Calendar`and `Locale`;
* Added support for Unicode 6.2.0 ;
* Added a standard class for working with Base64 ;
* Added support for unsigned arithmetic;
* Improved constructor `java.lang.String(byte[], *)` and method performance `java.lang.String.getBytes()`;
* A new implementation `AccessController.doPrivileged` that allows you to set a subset of privileges without having to check all * other access levels;
* Password-based algorithms have become more robust;
* Added support for SSL / TLS Server Name Indication (NSI) in JSSE Server ;
* Improved keystore (KeyStore);
* Added SHA-224 algorithm;
* Removed JDBC Bridge - ODBC;
* PermGen is removed , the method for storing meta-data of classes is changed;
* Ability to create profiles for the Java SE platform, which include not the entire platform, but some part of it;
* Tools
* Added utility `jjs` for using JavaScript Nashorn;
* The command `java` can run JavaFX applications;
* Added utility `jdeps` for analyzing .class files.
Method | Description |
---|---|
public final Class getClass() | returns the Class class object of this object. The Class class can further be used to get the metadata of this class. |
public int hashCode() | returns the hashcode number for this object. |
public boolean equals(Object obj) | compares the given object to this object. |
protected Object clone() throws CloneNotSupportedException | creates and returns the exact copy (clone) of this object. |
public String toString() | returns the string representation of this object. |
public final void notify() | wakes up single thread, waiting on this object\'s monitor. |
public final void notifyAll() | wakes up all the threads, waiting on this object\'s monitor. |
public final void wait(long timeout)throws InterruptedException | causes the current thread to wait for the specified milliseconds, until another thread notifies (invokes notify() or notifyAll() method). |
public final void wait(long timeout,int nanos)throws InterruptedException | causes the current thread to wait for the specified milliseconds and nanoseconds, until another thread notifies (invokes notify() or notifyAll() method). |
public final void wait()throws InterruptedException | causes the current thread to wait, until another thread notifies (invokes notify() or notifyAll() method). |
protected void finalize()throws Throwable | is invoked by the garbage collector before object is being garbage collected. |
Aggregation | Composition |
---|---|
Aggregation is a weak Association. | Composition is a strong Association. |
Class can exist independently without owner. | Class can not meaningfully exist without owner. |
Have their own Life Time. | Life Time depends on the Owner. |
A uses B. | A owns B. |
Child is not owned by 1 owner. | Child can have only 1 owner. |
Has-A relationship. A has B. | Part-Of relationship. B is part of A. |
Denoted by a empty diamond in UML. | Denoted by a filled diamond in UML. |
We do not use "final" keyword for Aggregation. | "final" keyword is used to represent Composition. |
Examples: - Car has a Driver. - A Human uses Clothes. - A Company is an aggregation of People. - A Text Editor uses a File. - Mobile has a SIM Card. | Examples: - Engine is a part of Car. - A Human owns the Heart. - A Company is a composition of Accounts. - A Text Editor owns a Buffer. - IMEI Number is a part of a Mobile. |
Abstraction | Encapsulation |
---|---|
Abstraction is a process of hiding the implementation details and showing only functionality to the user. | Encapsulation is a process of wrapping code and data together into a single unit |
Abstraction lets you focus on what the object does instead of how it does it. | Encapsulation provides you the control over the data and keeping it safe from outside misuse. |
Abstraction solves the problem in the Design Level. | Encapsulation solves the problem in the Implementation Level. |
Abstraction is implemented by using Interfaces and Abstract Classes. | Encapsulation is implemented by using Access Modifiers (private, default, protected, public) |
Abstraction means hiding implementation complexities by using interfaces and abstract class. | Encapsulation means hiding data by using setters and getters. |