☰ See All Chapters |
Java Tutorial
What is Java?
Java is a computer programming language - Java can create all kinds web sites, enterprise applications, bank applications, insurance applications, shopping sites, web application etc... that you could create using any conventional programming language.
Java was created in 1991 by James Gosling et al. of Sun Microsystems. Initially called oak, in honor of the tree outside Gosling's window, its name was changed to Java because there was already a language called oak.
What is the use of learning java?
Did you know that over three billion devices run the Java programming language? Bank applications, Insurance applications, shopping sites many more applications are built using java. If you know java, you can learn JEE, JME, JFX many testing and automation tools.
If you know JEE, you can develop enterprise applications, Bank applications, Insurance applications, shopping sites, web applications, web sites etc.
If you know java, you can learn android and can develop applications for mobile, smartphones and tablets.
If you know java, you can develop standalone applications, desktop applications.
If you know java, you can learn testing tools like selenium.
You have many options if you know java.
To learn java, is it required to have knowledge of any other programming language?
To learn java there are no prerequisites. Java is an independent language. Even it is good if don’t have knowledge of any other programming language, otherwise you may compare java with your other known language and lead to confusions.
Who can learn Java?
It is a misconception that only computer science engineers use Java, it is not true. Any engineers can learn java. In fact mechanical engineers have mastered java than computers science engineers. It is not limited to engineers; java is easy that anyone who works on computer can learn java. There are many instances of commerce and failed students, non-graduates who learnt java and they are leading life as java professionals.
Is Java Easy to Learn?
You may understand things slowly, but java is not hard to learn. Take some additional time and learn. Once you learn, you feel like Java is fun to learn. Take the advantage of editors like eclipse - an open source editor. As a beginner don’t try to learn using low level editors. Learn the concepts in an order, don’t jumble up. We have organized the topics for the readers. We might have skipped the topics which are not important or less important and those might be available in miscellaneous section. Beginners should not concentrate on complex topics in initial learning stage. The topics and contents which we have covered are well enough to learn java.
What is difference between Java and JEE?
Many students and developers have an assumption that JAVA and JEE are different languages. JEE (Java Enterprise Edition) is a java library used to create web applications, enterprise applications, web sites etc… JME (Java Micro Edition) is a java library used to create mobile applications, android applications etc… A library is readymade solution; you just have to learn how to use them. JEE, JME are not languages. In the world of JAVA there is only one language, i.e. JAVA. Rest all are libraries. To learn JEE, JME we first have to learn the basic language, Java.
What is the difference between JEE and J2EE?
JEE and J2EE both are same, Till java version 1.5, oracle retained ‘2’, in 1.6 version removed 2 from J2EE. So J2EE, J2ME and J2SE are not valid from 1.6 versions. Although these are correct way of stating, stop using 2 while stating.
Why java is popular?
Java is open source software, it is free to download.
Java is platform independent: java can run in any system line windows, Linux, mac etc.
Java is architecture neutral: Programs written today are supported even if the system configuration is changed, say processor is changed.
Java is portable: can be executed in any platform without any prerequisite installations.
What are the types of Java Application?
Java applications can be classified into below main four types:
Standalone applications
Web applications
Enterprise applications
Mobile applications
Standalone applications
Standalone applications are the desktop applications or windows based applications like Microsoft outlook, antivirus, media players etc… AWT and Swing are used to develop standalone applications. AWT and Swing are java libraries.
Web applications
Web application is a client server software application. Applications are run by the servers and accessed by users through browsers like Chrome, Mozilla etc… Servlet, JSP, JSF libraries are used to develop web applications. Wikipedia, Youtube, Gmail are the examples for web applications.
Enterprise applications
Enterprise applications are geographically distributed across different locations. Enterprise applications are capable of communicating with other applications, where other applications could be developed using non Java technologies too. Example shopping site communicates with bank application for the payments, here Shopping sit can be developed using Java and Bank application developed using Microsoft technologies, but still both applications communicate each other.
Mobile applications
Mobile applications are developed to run on mobile phones and tablets. Android applications should be developed using Java.
What are the different java editions?
There are main three editions of Java:
Java Standard Edition (Java SE)
This is the minimum requirement to run any java application. This package includes the below components:
Java Development Kit (JDK)
Java Virtual Machine (JVM)
Java Runtime Environment (JRE)
Java Class Library (JCL)
Java Enterprise Edition (Java EE)
It is an enterprise edition is used to develop web and enterprise applications. It has the libraries like servlet, JSP, Web Services, EJB, JPA, JAXP, JAXB, JMS etc.
Java Micro Edition (Java ME)
Java Micro Edition is used to develop applications running on mobile and on embedded devices.
How Java differs from C and C++?
Java is a lot like but the major difference between Java and C is that Java is an object-oriented language and has mechanism to define classes and objects whereas C structured programming language.
What is structured programming language?
Any language which is supporting the following three flow structures is called structured programming language
Sequence structure or step by step execution
Conditional Structure
Iterative Structure
Structured programming language follows water fall model. e.g. C, Pascal, Ada, ALGOL
What is the Difference between procedure oriented programming (POP) and structured programming?
Procedure oriented programming (POP) and structured programming is not different, a structured programming is a part of procedure oriented programming.
What are the different object oriented programming (OOP) Concepts?
Encapsulation: It is the Process of binding the data (state) and methods (behavior) together into a single unit.
Abstraction: Providing Essential properties and operations of an object by hiding internal things is called as Abstraction. Because of encapsulation, abstraction is possible and where there is no encapsulation there is no abstraction.
Inheritance: It is the concept of inheriting the properties of one class (super class) into another class (sub class) using IS a relationship. A class should be closed for modification but open for extension. Using inheritance we can add additional features to existing class without modifying it.
Polymorphism: One form behaving differently in different situations is called polymorphism. Polymorphism is extensively used in implementing inheritance. It helps in static and dynamic binding.
NOTE: OOP makes language highly reusable and can also avoid complexity.
What is the difference between POP (Procedure Oriented Programming) and OOP (Object Oriented Programming)?
POP is one type of project development, in the same way OOP is another type of project development.
Both are different approaches taken to complete a task.
POP follows waterfall model, whereas OOP follows spiral model
In POP data is global, can be accessed anywhere and there is no control over data .If it is modified then it will be affecting the other parts of the project.
In OOP data is secure, because access specifiers and encapsulation .High level of reusability and avoiding complexity of code is possible because of relationship between classes (IS a , HAS a)
In POP size of program is limited, but in OOP size can be limitless.
OOPs provide ability to simulate real world event much more effectively. We can provide the solution of real world problem if we are using the OOP.
What is the difference between object based and object oriented language?
Object based language not supports all OOP features
Object based language supports Encapsulation, Abstraction and compile time Polymorphism. E.g. JavaScript, VB5.0
Object based language doesn’t supports Inheritance and dynamic binding, run time polymorphism, dynamic polymorphism OOP includes object based and supports all OOP features. E.g. C++, Java etc.
What is the difference between partial OOP and Complete OOP?
In partial OOP we can define methods outside the class. E.g. C++
In complete OOP every function (methods in java) is defined inside the class.
Is java pure Object oriented?
No, java is not pure or 100% object oriented, because it is supporting primitive data types like int float etc. Java is having excellent performance because of existence of primitive data types (In some OOP languages int float etc.., are not primitive, they are also objects) .Java retained them as primitive because for better performance.
Complete OOP: All things should be inside class. E.g. Java
Pure OOP: All data types should be objects. E.g. Eiffel, Ruby, Small Talk
Java is Complete OOP, but not Pure OOP.
What is pure OOP language?
A pure OOP language should support following conditions.
Encapsulation
Abstraction
Inheritance
Polymorphism
All data types should be objects
NOTE: In case of Pure OOP primitive data types are also treated as objects. Java is structured, procedure oriented, Complete OOP, not Pure OOP.
What is the support given by java to implement OOP?
Java is supporting to implement OOP with the following user defined data types
Class data type
Sub class data type
Abstract data type
Interface data type
What is the difference between Java and C ?
| Java | C |
Unique statement keywords sizeof, and typedef | Absent | Present |
Data types struct and union | Absent | Present |
Type modifiers keywords auto, extern, register, signed, and unsigned | Absent | Present |
Explicit pointer type | Absent | Present |
preprocessor # define, # include, and # ifdef statements | Absent | Present |
instanceof Operator | Present | Absent |
break and continue statements | Present | Absent |
What is the difference between Java and C++ ?
Java | C++ |
Java source code or .java file is converted into a bytecode or .class file. JVM (Java Virtual Machine) interprets this bytecode. At runtime Just-In-Time (JIT) compiler will convert the part of code (code benefits from program execution point of view) to machine code with the help of an interpreter. So Java is both compiled as well as an interpreted language. | C++ executes the code by using only a compiler. The C++ compiler compiles and converts the source code into the machine code. |
Java is platform independent. | C++ is not platform independent. |
Java has multithreading support. | C++ has no multithreading support. |
Java is the only object-oriented programming language. | C++ is both a procedural and object-oriented programming language. |
Operator overloading is not supported in Java | Operator overloading is not supported in C++ |
Java does not have template classes | C++ has template classes |
Java does not support multiple inheritance of classes. Multiple inheritance is accomplished partially using interfaces | C++ supports multiple inheritance. |
Java does not support global variables. Every variable and method is declared within a class and forms part of that class. | C++ supports global variables. |
Java does not use pointers. | C++ supports pointers. |
Java has finalize() method for finalization. | C++ has destructor function for finalization. |
Java Environment
Java environment includes a large number of development tools and large collection of classes and methods. The development tools are part of the complete package known as Java Development Kit (JDK) and the classes and methods are part of the Java Standard Library (JSL), also known as the Application Programming Interface (API).
Folder organization when JDK 1.9 (java Development kit) is installed to Windows OS
All Chapters