- JAVA OVERVIEW
- History of Java
- Tools you will need for java
- Java Environment Setup
- Popular Java Editors
- Java Basic Syntax/First-Program
- Java Identifiers
- Java Modifiers
- Java Arrays
- Java Enums
- Java Keywords
- Comments in Java
- Java - Objects and Classes
- Objects in Java
- Classes in Java
- Constructors
- Creating an Object
- Accessing Instance Variables and Methods
- Source file declaration rules
- Java Package
- Simple Case Study
- Basic Data Types
- Primitive Data Types
- Reference Data Types
- Java Literals
- Variable Types
- Local variables
- Instance variables
- Class or static variables
- Java Access Modifiers
- What is OOPS
- Inheritance concept
- Encapsulation
- What is Polymorphism
- Method Overloading
- Method Overriding
- Abstraction in Java
- Abstract class
- Interface in Java
- Method overloading in Java:
- What is Annonymous object?
- Java 8
Java Basic Syntax
About Java programs, it is very important to keep in mind the following points.
Java is case sensitive which means identifier Hello and hello would have different meaning in Java.
Program :-
class ClassName
{
public static void main(String args[])
{
System.out.println("hello World...");
}
}
Syntax description of program :-
class :- Here, class is a predefined keyword in java and ClassName is an identifier(name of the class)it can be anything.
Then open braces.
Now start the method i.e main method from where execution is start.
public :- public is a modifier means we can access this method anywhere in the class or outside the class.
staic :- static is a keyword means we can access static method without the object or with the help of class name.Means no need to create the object to access static method.
void :- void is a return type that does not return any value.
main :- main is the name of main function this is a method from where execution is started.
String :- String is a class that is defined inside the java.lang packege.
args[] is an command line arguments.
Now open braces to set the statement for method.
System :- System is a class that is defined inside the java.lang package.
out :- out is the object of System class.
print :- print is an method of System class and ln use for new line(println).
close bracket.
close bracket.
java.lang package is an predefined java package.
Class Name :-
For all class names, the first letter should be in Upper Case. If several words are used to form a name of the class each inner words first letter should be in Upper Case.
Example class MyFirstJavaClass.
Method Names :-
All method names should start with a Lower Case letter. If several words are used to form the name of the method, then each inner word's first letter should be in Upper Case.
Example public void myMethodName().
File Name :-
Name of the program file should exactly match the class name. When saving the file you should save it using the class name (Remember Java is case sensitive) and append '.java' to the end of the name. (if the file name and the class name do not match your program will not compile).
Example : Assume 'MyFirstJavaProgram' is the class name. Then the file should be saved as
'MyFirstJavaProgram.java'
public static void main(String args[]) - java program processing starts from the main() method which is a mandatory part of every java program.
Java Basic Description
When we consider a Java program it can be defined as a collection of objects that communicate via invoking each other's methods. Let us now briefly look into what do class, object, methods and instance variables mean.
Object :- Objects have states, behaviors and identity.An object is an instance of a class. Example: A dog has states-color, name, breed as well as;
behaviors :- Wagging, barking, eating.
Class :- A class can be defined as a template/ blue print that describe the behaviors/states that object of its type support.
Methods :- A method is basically a behavior. A class can contain many methods. It is in methods where the logics are written, data is manipulated and all the actions are executed.
Instance Variables :- Each object has its unique set of instance variables. An object's state is created by the values assigned to these instance variables.It is declared inside the class and outside the methods. These variables can be accessed anywhere in the program or in class.
Local Variables :- The variables that declared inside the methods can not accessed outside the methods.The scope of local variables are only inside the methods.
static Variables :- The variables that declared by static keyword.we can accesse these variables without objects.