UNIT-I JAVA FUNDAMENTALS
MODULE-I BASICS OF JAVA
INTRODUCTION TO JAVA
Java Technology is
*A Programming
Language
*A Development
Environment
*An Application
Environment
*A Deployment
Environment
It
is originally developed by James Gosling, Sun Microsystems and now
it is developing by oracle. Very first, the java is called as oak.
It
is a language, easy to program because,
It
is eliminating many pitfalls of other language such as pointer, memory
management.
It
is fast, secure, and reliable.
It
is platform independent can run in any environment (since java codes are
converted into byte codes)
Before
Learning about java you should be aware of the below things..
JVM
Java
Virtual Machine which means imaginary
machine. The java program is compiled by the compiler and converts into byte
code (.class files) i.e.,
machine code then it is verified and run in interpreter.
GARBAGE
COLLECTION
To allocate/deallocate
memory pointers should be used in other programming languages whereas here
there is no need of pointers.
Garbage collection
happens automatically during the lifetime of java program, eliminating the need
to deallocate the memory and also avoiding the memory leaks
JRE
Java
Runtime Environment, it will load the code then verify the code and finally
executes code.
MODULE-II OOPS CONCEPTS
I hope you are all well known about
oops concept. So I skip this chapter.
MODULE-III IDENTIFIER,
KEYWORDS AND TYPES
IDENTIFIER:
Identifier is a name given to a variable,
class or method.
Following are valid identifiers to
be used in JAVA:
Username
username
user_name
_username
$username
KEYWORDS:
Abstract
|
Continue
|
For
|
New
|
Switch
|
Assert
|
Default
|
Goto
|
Package
|
Synchronized
|
Boolean
|
Do
|
If
|
private
|
This
|
Break
|
Double
|
Implements
|
Protected
|
Throw
|
Byte
|
Else
|
Import
|
Public
|
Throws
|
Case
|
Enum
|
instanceof
|
Return
|
transient
|
Catch
|
Extends
|
Int
|
Short
|
Try
|
Char
|
Final
|
Interface
|
Static
|
Void
|
Class
|
Finally
|
long
|
Strictfp
|
Volatile
|
DATA
TYPES
Eight primitive data
types are there in java programming language,
à Logical- boolean
e.g.: boolean a=true;
à Textual- char
e.g.: char a=’a’;
à Integral- byte,
short, int and
long
à Floating point- double and float
e.g.:double a=3.1415;
float a=3.414f
STRING
String is not a
primitive data type; it is a class to represent the sequence of the character.
e.g: String a=”hai, how
are you”;
MODULE-IV EXPRESSION
& FLOW CONTROL
VARIABLES
& SCOPE
There are two ways to describe variables:
à Variable
of primitive type
à Variable
of reference type
We can declare variable
inside a method or outside a method.
Variable which is
defined inside a method is called local variable. Sometime this is also called
as automatic, temporary or stacks variables.
Variable defined
outside a method are created when the object is constructed using the new abc() call. Variable
can be define outside a method in two ways,
à Using
static keyword is
called class variable.
à Without
using static keyword is
called as instance variable or member variable.
DEFAULT
VALUE OF PRIMITIVE TYPES
VARIABLE
|
VALUE
|
Byte
|
0
|
Short
|
0
|
Int
|
0L
|
Long
|
0.0F
|
Float
|
0.0D
|
Double
|
‘\u0000’
|
Boolean
|
False
|
All
reference types
|
null
|
OPERATORS
Important types of operators are there in java
programming language.
à Arithmetic
Operator (+, -, *, /)
à Logical
Operator (AND (&), OR (|), NOT (!), XOR (^))
à Short-circuit
logical Operator (&&, ||)
*****END*****
UNIT-II JAVA STANDARD
EDITION (J2SE)
MODULE I STRUCTURE OF JAVA
|
STRUCTURE
|
package
javaapplication3;
import java.lang.*;
public class Main
{
|
public static void main(String[] args)
{
System.out.println(“hello”);
}
}
public
static void main(String[] args)
public :- The method main() can be accessed by
anything including interpreter.
Static :- This keyword tells the compiler that the
main() method is used in the class. There is no need of instance to execute the
static method.
Void :- it indicates that the main function should
not return any value.
String args[] :- the main method is declare with a
single parameter “args” which is a type of String array.
COMPILING
AND RUNNING THE JAVA PROGRAM
Step1:
Type the program in a notepad and save as classname.java and place it in the C:\Program Files\Java\jdk1.7.0_17\bin
Step2
: open
the command prompt change the path to C:\Program
Files\Java\jdk1.7.0_17\bin and then to compile type javac classname.java, to run type java classname
Step3
: output
will be displayed.
No comments:
Post a Comment