A Java program can be defined as a collection of objects that communicate via invoking each other’s methods.
- Java is a Object-Oriented Language:
- Polymorphism
- Inheritance
- Encapsulation
- Abstraction
- Classes: A class can be defined as a template/blue print that describes the behaviors/states that object of its type support.
- Objects: Objects have states and behaviors.
- Instance
- Method
- Message Parsing
Inheritance:
In Java, classes can be derived from classes. Basically if you need to create a new class and here is already a class that has some of the code you require, then it is possible to derive your new class from the already existing code.
This concept allows you to reuse the fields and methods of the existing class without having to rewrite the code in a new class. In this scenario the existing class is called the superclass and the derived class is called the subclass.
Interfaces:
In Java language, an interface can be defined as a contract between objects on how to communicate with each other. Interfaces play a vital role when it comes to the concept of inheritance.
An interface defines the methods, a deriving class(subclass) should use. But the implementation of the methods is totally up to the subclass.
Variable Types inside Classes:
- Local variable: There is no default value for local variables so local variables should be declared and an initial value should be assigned before the first use.
- instance variable: When a space is allocated for an object in the heap, a slot for each instance variable value is created. Within static methods, instance variable should be called using the fully qualified name: ObjectReference.VariableName.
- class variable(with the static keyword): There would only be one copy of each class variable per class, regardless of how many objects are created from it: ClassName.VariableName
Java Data Types:
- Primitive Data Types:
- byte: 8-bit signed, -128(-2^7) ~ 127 (inclusive)(2^7 -1)
- short: 16-bit signed, -32,768(-2^15) ~ 32,767 (inclusive) (2^15 -1)
- int: 32-bit signed, -2,147,483,648(-2^31) ~ 2,147,483,647(inclusive)(2^31 -1)
- long: 64-bit signed, (-2^63) ~ (2^63-1)
- float: single-precision 32-bit,
- double: double-precision 64-bit, the default data type for decimal values.
- boolean: one bit, true and false.
- char: single 16-bit Unicode character, Minimum value is ‘\u0000’ (or 0), Maximum value is ‘\uffff’ (or 65,535 inclusive).
- Reference Data Types: Class
Java Class Types:
- abstract classes
- final classes
- Inner classes
- Anonymous classes.
Java Modifiers:
Like other languages, it is possible to modify classes, methods, etc., by using modifiers. There are two categories of modifiers:
- Access Modifiers:
- default: Visible to the package
- public: Visible to the world
- protected: Visible to the package and all subclasses
- private: Visible to the class only
- Non-access Modifiers:
- The static modifier for creating class methods and variables
- The final modifier for finalizing the implementations of classes, methods, and variables.
- The abstract modifier for creating abstract classes and methods.
- The synchronized and volatile modifiers, which are used for threads.
Java Basic Operators
http://www.tutorialspoint.com/java/java_basic_operators.html
The Bitwise Operators:
works on bits and performs bit-by-bit operation.
|
|
The instance of Operator:
|
|
Java Loop Control
|
|
Advanced for loop
Java Decision Making
|
|