Core Java
1) Introduction to Java
What Is Programming?
Programming is the process of creating a set of instructions that tell a computer how to perform a task.
Java Is a programming language and a platform.
Platform- Any hardware or software environment in which a program runs, is known as platform.
Since Java has its own runtime environment (JRE) and API it is called platform.
Java language developed at SUN Micro Systems in the year 1995 under the guidance of James Gosling and their team.
Java Version History
Now a day 11 versions of java are released.
Java divided into three categories, they are
1. J2SE (Java 2 Standard Edition)
2. J2EE (Java 2 Enterprise Edition)
3. J2ME (Java 2 Micro or Mobile Edition)
J2SE is used for developing client side applications.
J2EE is used for developing server side applications.
J2ME is used for developing mobile or wireless application by making use of a predefined protocol called WAP (wireless Access / Application protocol).
There are 3 stages of Java Application development,
1) Coding/Composition
2) Compilation 3) Execution
1) Coding: Developing a program according to java syntax (rules) is called as Coding. Note: All the java programs should be saved with file-name.java extension.
2) Compilation: Converting the java program written in high level language into byte code by using java compiler is called as Compilation.
Note: All the byte code will be stored as .class Extension
3) Execution: Converting the byte code into machine level language or processor understandable instructions using JVM is called as Execution (JVM is an Interpreter). Tokens
Tokens are smallest unit of a program that is meaningful to the compiler. There are 3 important tokens,
1) Keywords.
2) Literals.
3) Identifiers.
1) Keywords: This are pre-defined words in the programming language which will have some pre-defined meaning.
Example: class, public, static, void, etc. The Java programming language has total of 53 reserved keywords which have special meaning for the compiler and cannot be used as variable names. Rules to write keywords: All keywords must be written in lower case.
2) Identifiers: Programmer defined words are called as Identifier. Example: Name of variable, Name of a class, Name of a package, Name of an interface. Rules to write Identifier:
A) Identifier can be alphanumeric, no special characters are allowed except $, &, -. B) Identifier cannot start with a number but can start with an alphabet. C) Space is not allowed. D) Keywords cannot be Identifier.
3) Literals: Any constant value which can be assigned to the variable is called as literal/constant. There are 4 literals,
A) Numeric Literals:
Any number represented in java program will fall under numeric literals category.
B) Character Literals: Any character of the keyboards enclosed within single quote and 1 character within single quote is called as character literals. Example: ‘A’, ‘I’,’9’.
C) String Literals:
Anything which is enclosed within double quotes is considered as String literals. Example: “hello”, “hello123”.
D) Boolean Literals: There are only 2 Boolean literals True and False. To take decision we will use Boolean literals.
1) True and False are also called as reserved words.
2) 0 and 1 are not Boolean literals.
3) Using System.out.println();, we can print Literals
1) While writing java program, programmer should follow the condition of java programming language if the programmer is not following rules and conditions of java programs then java compiler will deploy Compile Time Error (CTE).
2) If the program results in compile time error, .class file won’t be generated.
Last modified 2yr ago
Copy link