0% found this document useful (0 votes)
58 views

Java Reaseach Paper

The document discusses Java programming language including its history, features, and key concepts like object-oriented programming, classes, objects, and constructors. It also covers topics like variables, methods, and singleton classes.

Uploaded by

Mukul
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views

Java Reaseach Paper

The document discusses Java programming language including its history, features, and key concepts like object-oriented programming, classes, objects, and constructors. It also covers topics like variables, methods, and singleton classes.

Uploaded by

Mukul
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Java programming language was originally developed by Sun Microsystems which was initiated by

James Gosling and released in 1995 as core component of Sun Microsystems' Java platform (Java 1.0
[J2SE]).

The latest release of the Java Standard Edition is Java SE 8. With the advancement of Java and its
widespread popularity, multiple configurations were built to suit various types of platforms. For
example: J2EE for Enterprise Applications, J2ME for Mobile Applications.

The new J2 versions were renamed as Java SE, Java EE, and Java ME respectively. Java is guaranteed
to be Write Once, Run Anywhere.

Java is:

 Object Oriented: In Java, everything is an Object. Java can be easily extended since it is based on
the Object model.

 Platform Independent: Unlike many other programming languages including C and C++, when Java
is compiled, it is not compiled into platform specific machine, rather into platform independent byte
code. This byte code is distributed over the web and interpreted by the Virtual Machine (JVM) on
whichever platform it is being run on.

 Simple: Java is designed to be easy to learn. If you understand the basic concept of OOP Java, it
would be easy to master.

 Secure: With Java's secure feature it enables to develop virus-free, tamper-free systems.
Authentication techniques are based on public-key encryption.

 Architecture-neutral: Java compiler generates an architecture-neutral object file format, which


makes the compiled code executable on many processors, with the presence of Java runtime
system.

 Portable: Being architecture-neutral and having no implementation dependent aspects of the


specification makes Java portable. Compiler in Java is written in ANSI C with a clean portability bo

Case Sensitivity - Java is case sensitive, which means identifier Helloand hello would have different
meaning in Java.

 Class Names - For all class names the first letter should be in Upper Case.

If several words are used to form a name of the class, each inner word's first letter should be in
Upper Case.

Example: class MyFirstJavaClass

 Method Names - All method names should start with a Lower Case letter.
If several words are used to form the name of the method, then each inner word's first letter should
be in Upper Case.

Example: public void myMethodName()

 Program File Name - Name of the program file should exactly match the class name.

When saving the file, you should save it using the class name (Remember Java is case sensitive) and
append '.java' to the end of the name (if the file name and the class name do not match, your
program will not compile).

Example: Assume 'MyFirstJavaProgram' is the class name. Then the file should be saved as
'MyFirstJavaProgram.java'

 public static void main(String args[]) - Java program processing starts from the main() method
which is a mandatory part of every Java program.

A class can contain any of the following variable types.

 Local variables: Variables defined inside methods, constructors or blocks are called local variables.
The variable will be declared and initialized within the method and the variable will be destroyed
when the method has completed.

 Instance variables: Instance variables are variables within a class but outside any method. These
variables are initialized when the class is instantiated. Instance variables can be accessed from inside
any method, constructor or blocks of that particular class.

 Class variables: Class variables are variables declared within a class, outside any method, with the
static keyword.

A class can have any number of methods to access the value of various kinds of methods. In the
above example, barking(), hungry() and sleeping() are methods.

Following are some of the important topics that need to be discussed when looking into classes of
the Java Language.

Constructors
When discussing about classes, one of the most important sub topic would be constructors. Every
class has a constructor. If we do not explicitly write a constructor for a class, the Java compiler builds
a default constructor for that class.

Java also supports Singleton Classes where you would be able to create only one instance of a class.

Note: We have two different types of constructors. We are going to discuss constructors in detail in
the subsequent chapters.

How to Use Singleton Class?

The Singleton's purpose is to control object creation, limiting the number of objects to only one.
Since there is only one Singleton instance, any instance fields of a Singleton will occur only once per
class, just like static fields. Singletons often control access to resources, such as database
connections or sockets.

For example, if you have a license for only one connection for your database or your JDBC driver has
trouble with multithreading, the Singleton makes sure that only on

The ClassicSingleton class maintains a static reference to the lone singleton instance and returns that
reference from the static getInstance() method.

Here, ClassicSingleton class employs a technique known as lazy instantiation to create the singleton;
as a result, the singleton instance is not created until the getInstance() method is called for the first
time. This technique ensures that singleton instances are created only when needed.

Creating an Object

As mentioned previously, a class provides the blueprints for objects. So basically, an object is created
from a class. In Java, the new keyword is used to create new objects.

There are three steps when creating an object from a class:

 Declaration: A variable declaration with a variable name with an object type.

 Instantiation: The 'new' keyword is used to create the object.

 Initialization: The 'new' keyword is followed by a call to a constructor. This call initializes the new
object.

You might also like