CORE JAVA
❖ Java:
1991
Sun Microsystem
“Oak” --- Hot java Browser
1995
JRE (Java Runtime Environment)
JDK (Java Development Kit)
JVM (Java Virtual Machine)
❖ What is Java?
Java is object-oriented programming (OOP) language. Java was invented
in 1991 in USA by ‘Sun Microsystem’. Java is first program was
developed/made was in Hot Java, which was a browser.
Java is platform independent program. Platform independent means java
can run in any type of OS until it has java software in it to run java. It does
not require a particular type of OS.
Another factor is portability. Java language is portable, which can be
moved easily from one computer system to another computer system
very easily.
It is multithreaded means we can do multiple tasks at this same time while
doing java programs, even we can access to various software at that
instant.
❖ Difference between java and C:
JAVA C
Java is object-oriented language, C is dependent on program.
which means it is dependent on
object.
Java does not support structure, C does support union and
union. structure.
Java doesn’t support pointer. C support pointer.
Java supports GUI (Graphical user C doesn’t support GUI.
interface)
❖ Difference between Java and C++:
JAVA C
Java does not support operator C++ Support operator overloading
overloading.
In java pointer is not used. In C++ pointer is used.
There is no header file in java. There is a header file in C++.
Java supports interface. Interface is not supported in C++.
❖ What do you mean by object-oriented programming?
OOP is dependent on object means it can access different- different items
at a same place is known as OOP.
❖ Features of Java:
I. Simple and small
II. Platform Independent
III. Portable
IV. Compiled and interpreter
V. Multithreaded
VI. High performance
VII. Object oriented
VIII. Rebuts and server
1) Simple and small: Java is a simple and small language; it does not support
many features of ’C’ and ‘C++’. Example: Java is a simple and small
language at it does not support the use of pointer as well as statement
and operator overloading.
2) Platform Independent: Java can run in any kind of OS, it only requires its
software to run, it doesn’t need a particular software or OS.
3) Portable: Java is a type of language, whose programs can be transferred
very easily from one computer to another computer system.
4) Compiler and Interpreted: Java does support compiler and interpreter
both. Java compiler converts source code into machine code and then java
directly runs the program.
5) Multithreaded: It means we can do multiple tasks at the same time, even
while doing java’s program. We can run any software.
6) High Performance: Java runs very fast and gives output instantly, as
compared to C and C++.
7) Object-Oriented: Java’s programs code and data object and class are
distributed in distinct section. Java program depends on class and object,
that’s why it is called object-oriented.
8) Rebuts and secure: The security level of many programs in higher in java
that in C++, because Java’s programs are difficult to run without JDK as
well as to run java’s programs, use have to set the path for it.
❖ Explain environmental of java?
Java environment does use various development tools, class and method.
Development tools are the part of JDK. However, class and method are
part of JSL (Java Standard Library) and API (Application Programming
Interface.)
❖ Explain JDK?
JDK is used to develop tools of java. Various tools of JDK are used to
identify and run the programs of java. The tools are listed below:
a) JAVA C: Java compiler
b) JAVA P: Converts byte code file into program
c) JAVA H: for header file
d) JAVA abc: for reading html document
e) JBD: java debugger to find errors
❖ JVM(Java Virtual Machine):
JVM converts java’s source code into machine code and this code and this
code known as byte code. The machine which is required for this
connection is called JVM.
JVM is inside the computer memory, while it is not necessary for any
machine to have a virtual code.
Java Program Java Virtual
compiler Machine
SOURCE CODE BYTE CODE
Fig 1: Process of compiler
Byte code Java Machine
Interpreter code
VIRTUAL MACHINE REAL MACHINE
Fig 2: Process of converting byte code into machine code
Java interpreter works as a mediator between byte code (which is inside
virtual machine) and machine code.
The layers of interactions for java program.
❖ Full Forms:
i. JDK: Java Development tool kit
ii. JVM: Java Virtual Machine
iii. JRE: Java Runtime environment
iv. JSP: Java Server page
v. JSDK: Java Server Development kit
vi. JIT: Just in time compiler
vii. JDBC: Java Database Connectivity
❖ Explain Public Static void main (String [] args):
i. Public main (): Public main () is call first in java program. Whenever
the program is run or executed. Public means we can access whole
program is data which is kept in the program anytime.
ii. static: Static keyword means in java environment program without
making instance in class, we can still call it. This methos is used to
declare statically.
iii. void main(): main method which can not be required so it is taken
with void data type.
iv. String args []: String args[] means arguments which are given in the
program. These are given as command line argument only in one
line (statement).
❖ Explain Java program structure:
Documentation Section Suggested
Package Statement Optional
Import Statement
Optional
Interface Statement
Optional
Class Definition Optional
Main method class
{
//code is here Essential
}
a) Documentation Section: this section includes comments line as
well as name of the program. This section also contains further
related details about the program. This section is used for comment
on documents.
b) Package Statement: the first statement in java program is package
statement. Package define the class for the program. Moreover, if
informs(call) compiler. However, class is not a part of package.
c) Import statement: this statement comes after package statement
and before the class. Import statement is similar to #include
statement. (it is in c, c++)
d) Interface statement: this statement is similar to class this is a group
of declaration method and this topic is optional. This statement is
used for multiple inheritance.
❖ Class Definition: Java program is a group of multiple class definition. Class
is the first and one of the important parts of java program with the help
of class, use can build an object. In any type of program, if the class
increases than its range and complexity increases.
❖ Main method class: methos is necessary for all programs. Program is
important data and member function are kept in main method. Main
method is an essential part of program.
❖ Data type: data type declares/ defines the type of value and specify the
size.
There are two types of primitive data:
i. Numeric
ii. Non-numeric
→Numeric:
→ Integer
→Floating point
Data Type in JAVA
Primitive Non-Primitive
Numeric Non-Numeric class Interface Array
Integer Floating point
Character Boolean
Integer type: in integer data type, integer value is stored.
E.g.; 32,14,114…
In this data type, we cannot store -94 ,-5643, etc; values.
Java supports 4 types of integer data type.
➔ Java does not support unsigned type.
Integer
Byte Short Int Long
❖ Size and Range of Integer types:
Type Size Minimum Maximum
Byte 1 byte -128 128
Short 2 bytes -32,768 32,767
Int 4 bytes -2,147,483,648 2,147,483,648
Long 8 bytes 036,854,772,808 036,854,775,808
➔ We identify long number by symbol ‘L’ and ‘l’. e.g.; 123L or 123l.