Introduction
Java created by James Gosling from sunmicrosystems(owned by oracle) in1991.The first publicly available version of java(java1.0)was released in 1995
History of java programming language
Java was initially designed by James Gosling and Naughton in 1992.The name suggested by james Gosling to the particular language is green talk and the extension is .gt.Originally java language designed to interactive telisivision,but it was too advanced to cable telivision industry.Initially the language terminated as oak.Laterally it was modifed in the year of 1995 as Java because of it was already trademark by oak technology.The small team of sun engineers called green team
Why oak name was suggested to the language
Oak is a symbol of strengthness like that language and it was treated as a national tree in so many countries
Why java name suggested to that particular language only
1.The green team start searching for new name to the particular language instead of oak .
2.They suggested names were"revolutionary","dynamic","silk","jolt","DNA",etc.
3.They wanted something that reflected importance of technology:revolutionary,dynamic,lively,cool,unique and easy to speak and funny to say
4.Java is an island of indonesia where the first coffee was produced and called java coffee

4.Java is an island of indonesia where the first coffee was produced and called java coffee


5.According to James Gosling java was one of the top choices along with silk.
So most of the green team members preffered the name java.
Symbol of java programming language is:
Basics concepts of of java programming language:
Java includes the language of c++ concepts they are :
Object :object is the runtime entity in an object oriented system.It may represent a person, a thing ,a bank account,a table of information and so many things. Objects have states and behaviour
For example : A student has states like school days, college days,employee stage days as well as behaviourlike good student or bad student and have good habbits or bad habbits
In oops a problem is analyzed in terms of objects and communication nature between them objects should match with the real-world objects.Objects takeup space in the memory and have an associated address like a structure in c.When a program is executed,the objects interact by sending messages to another.
In oops a problem is analyzed in terms of objects and communication nature between them objects should match with the real-world objects.Objects takeup space in the memory and have an associated address like a structure in c.When a program is executed,the objects interact by sending messages to another.
For example,if teacher and student are object to a program then the student object sending message to teacher object for requesting marks info.Each object contains data and code to manipulate data
OBJECT: college
Data:
employees
Salary payments
No.of.students
Functions:
Pass percentage
Grade of college
Class:
Class is a collection of similar objects that share the same properties,methods and semantics.Class is a user defined data type which holds data and its own members and member functions,which can be accessed and used by creating object. A clas can be defined as a template that can be describes the nature/state of the object.
Example: Consider the class of bikes. There may be many bikes with the different names and brands but all of them have have two wheels,speed,milage,minimum prize are their properties.
- A class is a userdefined data type that means(that can be given by users who used) has data members and member functions
- Data members are the variables which consists of data and member functions are functions that manipulate(modify) data.
- In the above example of class Bike,the data member will be speed limit,milage and member functions can be applide breaks to decrease or stop the Bike is member function.
Abstraction:
Hiding of unimportant data without knowing any internal structure. For example a driver can drive car without knowing internal structure like breaks can be applide on pascal law so it is not necessary to driver the basic thing that how he can drive with stereing.
Java is defined by a specification and consists of a programming language,a compiler,core libraries and a run time machine (java virtual machine)
The java runtime allows software developers to write programme code in other languages than the programming language which still runs on the java virtual machine
The platform is usually associated with the java virtual machine and the java core libraries
Inheritence
It is a process by which an object of one class acquires the properties and methods of another class.It supports the concept of hierachial classification.For example,your grand father is a parent to your father and your father is a parent to you,you acquires the sympotoms from your father and your father acquires symptoms from your grand father.
In oop,the concept of inheritance provides the idea of reusability.This means that we can add additional features to an existing class without modifying it.This ois possible by deriving a new class from existing one.The new class will have the combined feature of both the classes.The class from which the properties are acquired is called suoer class,and the class that acquies the properties is called sub class.This is mainly used for Method overloading and code reusability
Polymorphism
- Polymorphism means the ability to take more than one form.
- Polymorphism is a Greek term means an operation may exhibit different behaviour different instances.
- The behaviour depends upon the types of data used in the operation.
- In Java, we used method overloading and method overriding to achieve polymorphism.
For example can be to speak something e.g. Indians speak Hindi, Americans speaks English and Brtish speaks britan english
Advantages of OOP
- OOP offers several benefits to both the program designer and the user.
- Object-Orientation contributes to the solution of many problems associated with the development and quality of software products.
- The new technology promises greater programmer productivity, better quality of software and lesser maintenance cost.
The principal advantages are :
- It presents a simple, clear and easy to maintain structure
- software complexity can be easily managed
- It enhances program modularity since each object exists independently
- New features can be easily added without disturbing the existing one
- Objects can be reused in other program
- It allows designing and development safe programs using the data hiding
- Through inheritance, we can eliminate redundant code extend the use of existing classes
- It is easy to partition the work in a project based on objects
- Object-Oriented system can be easily upgraded from small to large system
- Message passing techniques for communication between objects makes to interface descriptions with external systems much simpler
Applications of OOP
- Application of OOP are beginning to gain importance in many areas.
- The most popular application of object-oriented programming, up to now, has been the area of user interface design such as window.
- Hundreds of windowing systems have been developed, using the OOP techniques.
The promising areas of application of OOP include
- Real-time systems
- simulation and modeling
- Object -Oriented data bases
- Hypertext,Hypermedia, and Expertext
- AI in expert systems
- Nuural networks parallel programming
- Decision support and Office automation systems
- CAM/CAD systems
Java Features/Buzz words
There are many features of java. They are also known as java buzz words. Some of the java features are given bellow
- Simple
- Secure
- Portable
- Object-oriented
- Robust
- Multithreaded
- Architecture-neutral
- Interpreted
- High performance
- Distributed
- Dynamic
Simple
Java inherits all the best features from the programming languages like C,C++ and thus makes it really easy for any developer to learn with little bit of programming experience. Removed many confusing and/or rarely-used features e.g., explicit pointers ,operator overloading etc. No need to remove unreferenced objects because there is Automatic Garbage Collection in java.
Secure
When Java programs are executed they don't instruct commands to the machine directly. Instead of Java Virtual Machine reads the program (Byte code) and convert it into the machine instructions. This way any program tries to get illegal access to the system will not be allowed by the JVM. Allowing Java programs to be executed by the JVM makes Java program fully secured under the control of the JVM.
Portable:
Portable means easy to move. Java programs are portable because Java is a platform independent language.Java programs have ability to run on any platform like windows, Linux, mac, etc .We can run java programs on android operating system also but the path directory should be correct.
Object Oriented:
Everything in Java is an Object. The object model in Java is simple and easy to extend, while primitive types, such as integers, are kept as high-performance non-objects.
Robust:
Robust means strong. the multi-platformed environment of the web places extraordinary on a program,because the program execute reliably in a variety of systems. Thus, the ability to create robust programs was given a high priority in the design of Java. Following features of Java make it robust.
- Platform Independent
- Object Oriented Programming Language
- Memory management
- Exception Handling
Multithreaded:
Java was designed to meet the real-world requirement of creating interactive, networked programs. To accomplish this, Java supports multithreaded programming, which allows you to write programs that do things simultaneously.
Architecture-neutral:
The Java designers made several hard decisions in the Java language and the Java virtual machine in an attempt to alter this situation. Their goal was----write once; run anywhere, anytime, forever .To a great extent,this goal was accomplished.
Interpreted and High Performance:
Java enables the creation of cross-platform programs by compiling into an intermediate representation called Java byte code. This code can be executed on any system that implements the Java Virtual Machine. Most previous attempts at cross-platform solutions have done so at the expence of performance . As explained earlier, the Java byte code was carefully designed so that it would be easy to translate directly into native machine code for very high performance by using a just-in-time compiler.
Distributed:
Java is designed for the distributed environment of the Internet because it handles TCP/IP protocols. In fact, accessing a resource using a URL is not much different from accessing a file. Java also supports Remote Method Invocation(RMI). This feature enables a program to invoke methods across a network.
Dynamic:
Dynamic means not constant(or)frequently changes. Java programs carry with them substantial amounts of run-time type information that is used to verify and resolve access to objects at run time. This makes it possible to dynamically link code in a safe and expedient manner
What is java virtual machine:
How it works:
The that allows Java to solve both the security and the portability problems is the byte code. The output of Java compiler not directly executable file. Rather it contains highly optimized set of instructions. these instructions are called "byte code". This byte code is designed to be executed by Java Virtual Machine (JVM). The JVM also called as the interpreter for byte code.
JVM also helps to solve many problems associated with web based programs. Translating a Java program into byte code makes it much easier to run a program in a wide variety of environments because only the JVM needs to be implemented for each platform to platform, all understand the same byte code. Thus, the execution of byte code by the JVM is the easiest way to create truly portable programs
Internal Architecture of JVM:
JVM is an abstract machine. It is a specification that provides run time environment in which Java byte code can be executed.
- JVMs are available for many hardware and software platforms(i.e. JVM is platform dependent).
- It is a specification where working of Java Virtual Machine is specified. But implementation provider is independent to choose the algorithm. Its implementation has been provided by Sun Microsystems and other companies.
- Its implementation is known as JRE(Java Runtime Environment).
- Whenever you write java command on the command prompt to run the Java class,ana instance of JVM is created.
What it does;
The JVM performs following operations:
- Loads code
- Verifies code
- Execute code
- Provides runtime environment
JVM provides definitions for the:
- Memory area
- Class file format
- Register set
- Garbage-collected heap
- Fatal error reporting etc.
Let us discuss about internal architecture about JVM. It contains class loader, memory area,execution engine etc
Class Loader:
class loader is a subsystem of JVM that is used to load class files
Class(method)Area:
Class(method) Area stores per-class structures such as the runtime constant pool, field and method data, the code for methods.
Heap:
It is the runtime data area in which objects are allocated.
Stack:
Stack means LIFO(last in first out).Java Stack stores frames. It holds local variables and partial results, and plays part in method invocation and return. Each thread has a private JVM stack, created at the same time as thread. A new frame is created each time a method is invoked. A frame is destroyed when its method invocation completes.
Program Counter(PC) Register:
PC(program counter) register. It contains the address of the Java virtual machine instruction which is currently being executed.
Native Method Stack:
It contains all the native methods used in the application. A native method is a java method (either instance method or a class method) whose implementation is written in another programming language such as C.
Execution engine:
It contains a
- virtual processor
- Interpreter: Read bytecode stream then execute the instructions.
- Just-In-Time compiler: It is used to improve the performance. JIT compiles parts of the byte code that have similar functionality at the same time, and hence reduces the amount of time needed for compilation.
Basic structure of Java Program
Basically a Java program involves the following sections:
- Documentation section
- Package Statement
- Import Statements
- Interface Statements
- Class Definition
- Main Method Class
- Main Method Definition
Documentation section:
It comprises a comment line which gives the name of program, the programmer's name and other brief details In Java there are Three styles of comments
- Single line(//)
- Multi-line(/* */)
- Documentation comment(/*…..*/)
Package statement:
The first statement allowed in Java is the Package statement. It is used to declare a package name and informs the compiler that the classes defined within the program belong to this package. It is declared as:
package package_name;
Import Statement:
The next statement is the number of import statements, which is equivalent to the #include statement in C++.
Example:
import java.util.scanner;
Interface Statements:
Interfaces are like a class that includes group of method declarations.This is an optional section and can be used only when programmer wants to implement multiple inheritances within a program.
Class Definition:
A Java program may contain multiple class definitions. Classes are the main and important elements of any Java program. These classes are used to plot the objects of the real world problem.
Main Method Class:
since every Java Standalone program requires the main methods as the starting point of the program. This class is essentially a part of Java program. A simple Java program contains only this part of the program.
To create a simple Java program, you need to create a class that contains main method. Let us discuss about the requirement first.
requirement for a Java welcome program Example:
For executing any Java program you need to
Install JDK(Java Development Kit ) if you don't have installed it, download and install it.
- Set path of JDK/BIN directory.
- Create the Java program
- Compile and Run the java program
Sample Code of "Welcome" Java program
Example:Welcome.java
class Welcome
{
public static void main(String[] args)
{
System.out.println("Welcome to Java");
}
}
Output:
Welcome to Java
Entering the Program
- We can use any text editor such as "notepad"(or)"dos text editor".
- The source code is typed and is saved with ".java" as an extension.
- The source code contains one or more class definitions. The program name will be same as class name in which main function is written. This is not compulsory, but by convention this is used
- The source file is officially called as compilation unit.
- We can uses our choice of interest names for the programs but we use same name(i.e) class name to be saved. If we use a different name than the class name, then compilation is done with program name, and running is done with the class file name. To avoid this confusion and organize the programs well, it is suggested to put the same name for the program and class name, but not compulsory.
Compiling the program:
To compile the program, specifying the name of the source file on the command line,
For example:
C:/>javac Welcome.java
Here the javac compiler creates the file called "Welcome.java class" that contains the byte code version of the source code. that contains instructions that the Java Virtual Machine(JVM) will execute. Thus the output of the javac is not directly executable code.
Running the Java program:
To run the Java program, we must use java interpreter, called "java" .This is interpreter the "Welcome.class" file given as input.
C:/>java welcome
when the program undergoes to run with the interpreter the output of the given input produced as follows
welcome to java
Explanation about program:
- the first line in the program(class welcome) the "class" is a keyword and "welcome" is a class name which are basic unit for encapsulation and is used to declare a class in java, in which class and methods are declared.
- The second line contains"{"is indicates beginning of the class
- The third line consists public static void main(String args [])
where
- public is a keyword which acts as an access modifier which represents visibility, it means it is visible to all
- Static is a keyword, if we declare any method as static, it is known as static method. The main advantage of static keyword is there is no need to create object to invoke the static method . The main method is executed by the JVM. So it does not require to create the object to invoke the main method. So it saves memory.
- void is the return type of method, it means it does not return any value.
- main represents startup of the program where execution starts.
- String[] args is used to read command line arguments.
Fourth line contains"{" which indicates beginning of the main program
Fifth line contains
"System.out.println("Hello World)";
Here "System"is a predefined class , that provides access to the system, and out is the output stream that is used to connect the console. The println is used to display string passed to it. This can even display other information too.
Lexical issues:
Java programs are collection of whitespace, identifiers, literals, comments, operators, separators, and keywords.
Whitespace:
Java is a free-form language. This means that you do not need to follow any special indentation rules. For example, the Java could be written all on one line or in any other strange way you left like typing it, as long as there was at least one white space character between each token that was not already delineated by an operator or separator. In Java, white space is a space, tab, or newline.
Identifiers:
Identifiers are used to name things, such as classes, variables, and methods.
- An identifier may be any descriptive sequence of uppercase and lowercase letters, numbers, or the underscore and dollar -sign characters.
ex: Car, An Object; myPROgrAM 123
- They must not begin with a number. Java is case-sensitive, so VALUE is a different identifier than value.
- keywords cannot be used as identifiers
Variables:
variable is name of reserved area allocated in memory
ex:int data=50;//here data is variable
Types of variables:
there are three types of variables in java they are:
- local variable
- instance variable
- static variable
Local variable:
A variable that is declared inside the method is called local variable
Instance variable:
A variable that is declared inside the class but outside the method is called instance variable
Static variable:
A variable that is declared inside the class but outside the method is called instance variable
Static variable:






Well-done 👍👏👏
ReplyDeleteTq
DeleteWe want more info
ReplyDeleteSuper
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDeleteGood blog where i am able to gather a lot of worthy information.
ReplyDeletejava training in coimbatore
java course in coimbatore
java training in bangalore
Best Java Training Institutes in Bangalore
java training in madurai
best java training institute in madurai
Definitely I'll tell the details brother
Delete