Principles of Java programming

Originally known as oak, Java is a programming language developed by James Gosling and others at Sun Microsystems. It was first introduced to the public in 1995 and is widely used to create Internet applications and other software programs. Today, Java is maintained and owned by Oracle.
When used on the Internet, Java allows applets to be downloaded and used through a browser, which enables the browser to perform a function or feature not normally available. Unlike JavaScript, the users must download or install the applet or program before being able to utilize the Java program.
Below is an example of a Java applet from Sun and a method of testing if Java is installed on your computer. If Java is installed on your computer, you should see additional information about the installed Java version and your operating system.
Java is also used as the programming language for many different software programs, games, and add-ons. Some examples of the more widely used programs written in Java or that use Java include the Adobe Creative suite, Eclipse, Lotus Notes, Minecraft, OpenOffice, Runescape, and Vuze.
Java virtual machine (JVM)
Java is a high level programming language. A program written in high level language cannot be run on any machine directly. First, it needs to be translated into that particular machine language. The javac compiler does this thing, it takes java program (.java file containing source code) and translates it into machine code (referred as byte code or .class file).
A Java virtual machine (JVM) is an abstract computing machine that enables a computer to run a Java program. There are three notions of the JVM: specification, implementation, and instance. The specification is a document that formally describes what is required of a JVM implementation. Having a single specification ensures all implementations are interoperable. A JVM implementation is a computer program that meets the requirements of the JVM specification. An instance of a JVM is an implementation running in a process that executes a computer program compiled into Java bytecode.
Java Runtime Environment (JRE)
Java Runtime Environment (JRE) is a software package that contains what is required to run a Java program. It includes a Java Virtual Machine implementation together with an implementation of the Java Class Library. The Oracle Corporation, which owns the Java trademark, distributes a Java Runtime environment with their Java Virtual Machine called HotSpot.
Java Development Kit (JDK)
Java Development Kit (JDK) is a superset of a JRE and contains tools for Java programmers, e.g. a javac compiler. The Java Development Kit is provided free of charge either by Oracle Corporation directly, or by the OpenJDK open source project, which is governed by Oracle.
JVM Vs JRE Vs JDK
JRE: JRE is the environment within which the java virtual machine runs. JRE contains Java virtual Machine(JVM), class libraries, and other files excluding development tools such as compiler and debugger.
Which means you can run the code in JRE but you can t develop and compile the code in JRE.
JVM: As we discussed above, JVM runs the program by using class, libraries and files provided by JRE.

JDK: JDK is a superset of JRE, it contains everything that JRE has along with development tools such as compiler, debugger etc.

Java Class
A class is a group of objects which have common properties. It is a template or blueprint from which objects are created. It is a logical entity. It can’t be physical.
A class in Java can contain:
o fields
o methods
o constructors
o blocks
o nested class and interface
Syntax to declare a class:
1. class {
2. field;
3. method;
4. }

Java Methods
A Java method is a collection of statements that are grouped together to perform an operation. When you call the System.out.println() method, for example, the system actually executes several statements in order to display a message on the console.
Now you will learn how to create your own methods with or without return values, invoke a method with or without parameters, and apply method abstraction in the program design.
Creating Method
Considering the following example to explain the syntax of a method
Syntax
public static int methodName(int a, int b) {
// body
}
Here,
public static modifier
int return type
methodName name of the method
a, b formal parameters
int a, int b list of parameters
Method definition consists of a method header and a method body. The same is shown in the following syntax
Syntax
modifier returnType nameOfMethod (Parameter List) {
// method body
}
The syntax shown above includes
modifier It defines the access type of the method and it is optional to use.
returnType Method may return a value.
nameOfMethod This is the method name. The method signature consists of the method name and the parameter list.
Parameter List The list of parameters, it is the type, order, and number of parameters of a method. These are optional, method may contain zero parameters.
method body The method body defines what the method does with the statements.
Example
Here is the source code of the above defined method called min(). This method takes two parameters num1 and num2 and returns the maximum between the two
/** the snippet returns the minimum between two numbers */

public static int minFunction(int n1, int n2) {
int min;
if (n1 > n2)
min = n2;
else
min = n1;

return min;
}
Object-Oriented
In this page, we will learn about basics of OOPs. Object Oriented Programming is a paradigm that provides many concepts such as inheritance, data binding, polymorphism etc.
Simula is considered as the first object-oriented programming language. The programming paradigm where everything is represented as an object, is known as truly object-oriented programming language.
Smalltalk is considered as the first truly object-oriented programming language.
Object means a real word entity such as pen, chair, table etc. Object-Oriented Programming is a methodology or paradigm to design a program using classes and objects. It simplifies the software development and maintenance by providing some concepts:
o Object
o Class
o Inheritance
o Polymorphism
o Abstraction
o Encapsulation
Object
Any entity that has state and behavior is known as an object. For example: chair, pen, table, keyboard, bike etc. It can be physical and logical.
Class
Collection of objects is called class. It is a logical entity.
Inheritance
When one object acquires all the properties and behaviours of parent object i.e. known as inheritance. It provides code reusability. It is used to achieve runtime polymorphism.

Polymorphism
When one task is performed by different ways i.e. known as polymorphism. For example: to convince the customer differently, to draw something e.g. shape or rectangle etc.
In java, we use method overloading and method overriding to achieve polymorphism.
Another example can be to speak something e.g. cat speaks meaw, dog barks woof etc.
Abstraction
Hiding internal details and showing functionality is known as abstraction. For example: phone call, we don’t know the internal processing.
In java, we use abstract class and interface to achieve abstraction.

Encapsulation
Binding (or wrapping) code and data together into a single unit is known as encapsulation. For example: capsule, it is wrapped with different medicines.
A java class is the example of encapsulation. Java bean is the fully encapsulated class because all the data members are private here.
Reasons for choice of java language
Java has been the best programming languages created in last 20 years and has been gaining popularity every passing day. Although there were occasions when Java development slowed down, but with path breaking changes in form of Enum, Autoboxing and Generics in Java 5, Google s choice of language for Android apps development and performance improvement with Java 6, kept Java as top programming language. Also In terms of Job opportunities and popularity, Java outscore every one with lots of Jobs opportunity available. You can work on developing core Java based server side application, can even go for Android based mobile application development , J2EE web and enterprise applications.
Here are top 10 reason for Learning Java Programming Language
1) Java is easy to learn
Java has fluent English like syntax which makes it easy to read Java program and learn quickly. Once you are familiar with initial hurdles with installing JDK and setting up PATH and understand How Classpath works, it s easy to write program in Java.
2) Java is an object oriented programming Language
Java is an Object Oriented Programming language. Developing OOPS application is easier, and it also helps to keep system modular, flexible and extensible. You can use all key concepts like Abstraction, Encapsulation, Polymorphism and Inheritance. Java also promotes use of SOLID and Object oriented design principles in form of open source projects like spring, which make sure your object dependency is well managed by using dependency Injection principle.
3) Java has Rich API
Java provides API for networking, I/O, utilities, XML parsing, database connection, and almost everything. Whatever left is covered by open source libraries like Apache Commons, Google Guava and others.
4) Powerful development tools e.g. Eclipse, Netbeans
Eclipse and Netbeans has played huge role to make Java one of the best programming language. Coding in IDE is a treat, especially if you have coded in DOS Editor or Notepad. They not only help in code completion but also provide powerful debugging capability, which is essential for development and testing. Integrated Development Environment made Java development much easier, faster and fluent. Apart from IDE, Java platform also has several other tools like Maven and ANT for building Java applications, JConsole, decompilers, Visual VM for monitoring Heap usage etc.
5) Good collection of Open Source libraries
Open source libraries ensures that Java should be used everywhere. Apache, Google, and other organization has contributed lot of great libraries, which makes Java development easy, faster and cost effective. There are framework like Spring, Struts, Maven, which ensures that Java development follows best practices of software craftsmanship, promotes use of design patterns and assisted Java developers to get there job done.
6) Great community support
Community is the biggest strength of Java programming language and platform. Java has lots of active forums, Stackoverflow, open source organizations and several Java user group to help everything. There is community to help beginners, advanced and even expert Java programmers. Java actually promotes taking and giving back to community habit. Expert programmer provides advice for FREE at various Java forums and stackoverflow.
7) Java is FREE
Since Java is free i.e. you don t need to pay anything to create Java application. This FREE thing also helped Java to become popular among individual programmers, and among large organizations.
8) Excellent documentation support with Javadocs
Javadocs is a great piece of documentation, which tells lot of things about Java API. Not everyone has time and intention to look at code to learn. Javadocs makes learning easy, and provide an excellent reference while coding in Java.
9) Platform Independent
Java s tag line write once run anywhere was the main reason of Java s popularity.This is still one of the reason of Java being best programming language, most of Java applications are developed in Windows environment and run in UNIX platform.
10) Java is everywhere
Yes, Java is everywhere, it s on desktop, mobile, almost everywhere and so are Java programmers. Organization prefers to choose Java for new development than any other programming language.
Having said that, programming is very big field and if you look at C and UNIX, which is still surviving and even stronger enough to live another 20 years, Java also falls in same league.
Java Organizational policy
Some organisations have policies on what software and hardware can be used, this may affect the decision on what language to use. For example Craven College uses the Windows Operating System because they teach programming using VB.NET, which requires Windows as it was developed by Microsoft. Another example would be that companies that develop applications for Apple devices would use Objective-C or Swift which are languages developed by Apple for use with their devices.
They also may have policies related on what language to use. Like Google has a policy to use Python which they use for most of their applications. This is chosen as the language Google uses because they focus a lot on making applications for the web.

Suitability of features and tools
The suitability of the features and tools of a programming language are important when choosing a programming language. With a wide variety of programming languages available, there are also many different features which are specific to certain languages. The company needs to analyse these features to ascertain whether the features can be used to meet the requirements of the system. They also need to consider whether the language only works with specific software/hardware.
Availability of Trained Staff
When choosing a language, an organisation should consider what past experiences the employees have with programming and if there is a common language that they all know how to use. They should also consider the skill level of each member of the team and whether they can develop their skill level enough for the language to be used. If the organisation is working on a project where they have to develop a new system and the organisation needs to recruit specialist, the organisation should choose a language that is more commonly used as it is more likely that there will be more experienced programmers in that language.
Reliability
Certain programming languages have features that allow the programmer to improve the reliability of their program. This can be because the programming language has combined features of the different programming paradigms or elements specific to the programming language such as a debugger and editor which identifies errors and stops the program from crashing.
Development and Maintenance
When continuously using a programming language, the company has to think about the development and maintenance costs of the software. They need to consider how much the software license is and for how long they will be using the software for. Some languages are easy to develop and maintain but are also inexpensive.
Expandability
Expandability is key when choosing a programming language. The company needs to choose a language that is easily expandable and allows the programmers to create a program that can sustain multiple users without crashing. Some programming languages are more expandable than others and have features that can support the larger systems that may be programmed.
Uses of Specific Programming Languages
Below are some common websites that use specific programming languages and also some popular companies that use specific programming languages.
Object Methods
A method in object-oriented programming (OOP) is a procedure associated with a message and an object. An object is mostly made up of data and behavior, which form the interface that an object presents to the outside world. Data is represented as properties of the object and behavior as methods. For example, a Window object would have methods such as open and close, while its state (whether it is opened or closed) would be a property.
In class-based programming, methods are defined in a class, and objects are instances of a given class. One of the most important capabilities that a method provides is method overriding. The same name (e.g., area) can be used for multiple different kinds of classes. This allows the sending objects to invoke behaviors and to delegate the implementation of those behaviors to the receiving object. A method in Java programming sets the behavior of a class object. For example, an object can send an area message to another object and the appropriate formula is invoked whether the receiving object is a rectangle, circle, triangle, etc.
Object
Let us now look deep into what are objects. If we consider the real-world, we can find many objects around us, cars, dogs, humans, etc. All these objects have a state and a behavior.
If we consider a dog, then its state is – name, breed, color, and the behavior is – barking, wagging the tail, running.
If you compare the software object with a real-world object, they have very similar characteristics.
Software objects also have a state and a behavior. A software object’s state is stored in fields and behavior is shown via methods.
So in software development, methods operate on the internal state of an object and the object-to-object communication is done via methods.
Inheritance
Inheritance in java is a mechanism in which one object acquires all the properties and behaviors of parent object. The idea behind inheritance in java is that you can create new classes that are built upon existing classes. When you inherit from an existing class, you can reuse methods and fields of parent class, and you can add new methods and fields also.
Inheritance represents the IS-A relationship, also known as parent-child relationship.
Why use inheritance in java
For Method Overriding (so runtime polymorphism can be achieved).
For Code Reusability.
Syntax of Java Inheritance
1. class Subclass-name extends Superclass-name
2. {
3. //methods and fields
4. }

The extends keyword indicates that you are making a new class that derives from an existing class. The meaning of “extends” is to increase the functionality.
In the terminology of Java, a class which is inherited is called parent or super class and the new class is called child or subclass.
Java Inheritance Example

As displayed in the above figure, Programmer is the subclass and Employee is the superclass. Relationship between two classes is Programmer IS-A Employee.It means that Programmer is a type of Employee.
1. class Employee{
2. float salary=40000;
3. }
4. class Programmer extends Employee{
5. int bonus=10000;
6. public static void main(String args[]){
7. Programmer p=new Programmer();
8. System.out.println(“Programmer salary is:”+p.salary);
9. System.out.println(“Bonus of Programmer is:”+p.bonus);
10. }
11. }

Polymorphism
Polymorphism is the ability of an object to take on many forms. The most common use of polymorphism in OOP occurs when a parent class reference is used to refer to a child class object. Any Java object that can pass more than one IS-A test is considered to be polymorphic. In Java, all Java objects are polymorphic since any object will pass the IS-A test for their own type and for the class Object. It is important to know that the only possible way to access an object is through a reference variable. A reference variable can be of only one type. Once declared, the type of a reference variable cannot be changed. The reference variable can be reassigned to other objects provided that it is not declared final. The type of the reference variable would determine the methods that it can invoke on the object. A reference variable can refer to any object of its declared type or any subtype of its declared type. A reference variable can be declared as a class or interface type.
Runtime Polymorphism in Java
Runtime polymorphism or Dynamic Method Dispatch is a process in which a call to an overridden method is resolved at runtime rather than compile-time.
In this process, an overridden method is called through the reference variable of a superclass. The determination of the method to be called is based on the object being referred to by the reference variable.
Let’s first understand the upcasting before Runtime Polymorphism.
Upcasting
When reference variable of Parent class refers to the object of Child class, it is known as upcasting. For example:

1. class A{}
2. class B extends A{}
1. A a=new B();//upcasting

Example of Java Runtime Polymorphism
In this example, we are creating two classes Bike and Splendar. Splendar class extends Bike class and overrides its run() method. We are calling the run method by the reference variable of Parent class. Since it refers to the subclass object and subclass method overrides the Parent class method, subclass method is invoked at runtime.
Since method invocation is determined by the JVM not compiler, it is known as runtime polymorphism.
1. class Bike{
2. void run(){System.out.println(“running”);}
3. }
4. class Splender extends Bike{
5. void run(){System.out.println(“running safely with 60km”);}
6.
7. public static void main(String args[]){
8. Bike b = new Splender();//upcasting
9. b.run();
10. }
11. }

Encapsulation
Encapsulation is one of the four fundamental OOP concepts. The other three are inheritance, polymorphism, and abstraction.
Encapsulation in Java is a mechanism of wrapping the data (variables) and code acting on the data (methods) together as a single unit. In encapsulation, the variables of a class will be hidden from other classes, and can be accessed only through the methods of their current class. Therefore, it is also known as data hiding.
To achieve encapsulation in Java
Declare the variables of a class as private.
Provide public setter and getter methods to modify and view the variables values.
Example
Following is an example that demonstrates how to achieve Encapsulation in Java
/* File name : EncapTest.java */
public class EncapTest {
private String name;
private String idNum;
private int age;

public int getAge() {
return age;
}

public String getName() {
return name;
}

public String getIdNum() {
return idNum;
}

public void setAge( int newAge) {
age = newAge;
}

public void setName(String newName) {
name = newName;
}

public void setIdNum( String newId) {
idNum = newId;
}
Private, Public and Protected Class
You must have seen public, private and protected keywords while practising java programs, these are called access modifiers. An access modifier restricts the access of a class, constructor, data member and method in another class. In java we have four access modifiers:
1. private
2. public
3. protected
1.Private access modifier
The scope of private modifier is limited to the class only.
1. Private Data members and methods are only accessible within the class
2. Class and Interface cannot be declared as private
3. If a class has private constructor then you cannot create the object of that class from outside of the class.
Let s see an example to understand this:
Private access modifier example in java
This example throws compilation error because we are trying to access the private data member and method of class ABC in the class Example. The private data member and method are only accessible within the class.
class ABC{
private double num = 100;
private int square(int a){
return a*a;
}
}
public class Example{
public static void main(String args[]){
ABC obj = new ABC();
System.out.println(obj.num);
System.out.println(obj.square(10));
}
}
Output:
Compile – time error

2.Public access modifier
The members, methods and classes that are declared public can be accessed from anywhere. This modifier doesn t put any restriction on the access.
Public access modifier example in java
Lets take the same example that we have seen above but this time the method addTwoNumbers() has public modifier and class Test is able to access this method without even extending the Addition class. This is because public modifier has visibility everywhere.
Addition.java
package abcpackage;

public class Addition {

public int addTwoNumbers(int a, int b){
return a+b;
}
}
Test.java
package xyzpackage;
import abcpackage.*;
class Test{
public static void main(String args[]){
Addition obj = new Addition();
System.out.println(obj.addTwoNumbers(100, 1));
}
}
Output:
101

3.Protected Access Modifier
Protected data member and method are only accessible by the classes of the same package and the subclasses present in any package. You can also say that the protected access modifier is similar to default access modifier with one exception that it has visibility in sub classes.
Classes cannot be declared protected. This access modifier is generally used in a parent child relationship.
Protected access modifier example in Java
In this example the class Test which is present in another package is able to call the addTwoNumbers() method, which is declared protected. This is because the Test class extends class Addition and the protected modifier allows the access of protected members in subclasses (in any packages).
Addition.java
package abcpackage;
public class Addition {

protected int addTwoNumbers(int a, int b){
return a+b;
}
}
Test.java
package xyzpackage;
import abcpackage.*;
class Test extends Addition{
public static void main(String args[]){
Test obj = new Test();
System.out.println(obj.addTwoNumbers(11, 22));
}
}
Output:
33

Private methods in Java
When we use final specifier with a method, the method cannot be overridden in any of the inheriting classes. Methods are made final due to design reasons.
Since private methods are inaccessible, they are implicitly final in Java. So adding final specifier to a private method doesn t add any value. It may in-fact cause unnecessary confusion.
class Base {

private final void foo() {}

// The above method foo() is same as following. The keyword
// final is redundant in above declaration.

// private void foo() {}
}
For example, both program 1 and program 2 below produce same compiler error foo() has private access in Base .
Program 1
// file name: Main.java
class Base {
private final void foo() {}
}

class Derived extends Base {
public void foo() {}
}

public class Main {
public static void main(String args[]) {
Base b = new Derived();
b.foo();
}
}
Program 2
// file name: Main.java
class Base {
private void foo() {}
}

class Derived extends Base {
public void foo() {}
}

public class Main {
public static void main(String args[]) {
Base b = new Derived();
b.foo();
}
}
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Public methods in Java
The members, methods and classes that are declared public can be accessed from anywhere. This modifier doesn t put any restriction on the access. Lets take the same example that we have seen above but this time the method addTwoNumbers() has public modifier and class Test is able to access this method without even extending the Addition class. This is because public modifier has visibility everywhere.
Summary of the Modification Accessibility
Modifiers are keywords that you add to those definitions to change their meanings. Java language has a wide variety of modifiers, including the following
Java Access Modifiers
Non Access Modifiers
To use a modifier, you include its keyword in the definition of a class, method, or variable. The modifier precedes the rest of the statement, as in the following example.
Example
public class className {
// …
}

private boolean myFlag;
static final double weeks = 9.5;
protected static final int BOXWIDTH = 42;

public static void main(String[] arguments) {
// body of method
}
Access Control Modifiers
Java provides a number of access modifiers to set access levels for classes, variables, methods and constructors. The four access levels are
Visible to the package, the default. No modifiers are needed.
Visible to the class only (private).
Visible to the world (public).
Visible to the package and all subclasses (protected).
Non-Access Modifiers
Java provides a number of non-access modifiers to achieve many other functionality.
0The static modifier for creating class methods and variables.
The final modifier for finalizing the implementations of classes, methods, and variables.
The abstract modifier for creating abstract classes and methods.
The synchronized and volatile modifiers, which are used for threads.
Data structures
Public instance variables:
An instance variable is a variable/attribute/member that is associated with an instance. So if we have a Person class, and we have an instance of a Person called Bob, then things like Bob.age or Bob.haircolor would be instance variables. A public instance variable is just an instance variable that is public. That is, you are allowed to use the instance variable from outside the class.
Private instance variables:
The private (most restrictive) modifiers can be used for members but cannot be used for classes and Interfaces. Fields, methods or constructors declared private are strictly controlled, which means they cannot be accessed by anywhere outside the enclosing class.
Naming conventions:
Different Java programmers can have different styles and approaches to the way they program. By using standard Java naming conventions they make their code easier to read for themselves and for other programmers. Readability of Java code is important because it means less time is spent trying to figure out what the code does, leaving more time to fix or modify it. A naming convention is a rule to follow as we decide what to name our identifiers (e.g. class, package, variable, method, etc.).
Arrays (One & Two dimensional):
An array is a collection of variables that are of similar data types and are referred by a common name. A specific element in an array is accessed by a particular index of that array. A one-dimensional array is a list of variables with the same data type, whereas the two-Dimensional array is array of arrays having similar data types.
File structure:
If Point is defined as a public class, its source code must appear in a file named Point.java. Regardless of whether the classes are public or not, it is good programming practice to define only one per file and to give the file the same name as the class.
Loops:
A loop statement permits us to execute an announcement or gathering of statements numerous times and taking after is the general type of a loop statement in a large portion of the programming languages. Loops are grouping of guideline that is consistently rehashed until a specific condition came to.
Conditional statements:
Java, like all other programming languages, is equipped with specific statements that allow us to check a condition and execute certain parts of code depending on whether the condition is true or false. Such statements are called conditional, and are a form of composite statement.
Case statements:
A switch statement allows a variable to be tested for equality against a list of values. Each value is called a case, and the variable being switched on is checked for each case.
Logical operators:
If we assume Boolean variables A holds true and variable B holds false, then
&& is called Logical AND operator. If both the operands are non-zero, then the condition becomes true. For example (A && B) is false.
|| is called Logical OR Operator. If any of the two operands are non-zero, then the condition becomes true. For example (A || B) is true.
! (Logical not) Called Logical NOT Operator. Use to reverses the logical state of its operand. If a condition is true then Logical NOT operator will make false. For example !(A && B) is true.
Assignment statements:
Java programs store data values in variables. When a programmer creates a variable in a Java application, he declares the type and name of the variable, then assigns a value to it. The value of a variable can be altered at subsequent points in execution using further assignment operations. The assignment statement in Java involves using the assignment operator to set the value of a variable.
Input statements:
This is used to feed the data to user’s program and usually a keyboard is used as standard input stream and represented as System.in.
Output statements:
This is used to output the data produced by the user’s program and usually a computer screen is used for standard output stream and represented as System.out.
Data types
Constants and literals:
A constant in Java is used to map an exact and unchanging value to a variable name. A literal is a value that is expressed as itself. For example, the number 25 or the string “Hello World” are both literals.
Integer: It is a whole number with no fractional value that can be positive, negative, or zero.
Floating point:
These are numbers that have fractional parts (usually expressed with a decimal point).
Byte:
Byte data type is an 8-bit signed two’s complement integer. The minimum value is -128 & maximum value is 127. Default value is 0. Byte data type is used to save space in large arrays, mainly in place of integers, since a byte is four times smaller than an integer.
Date:
Date ( ) constructor initializes the object with the current date and time.
Boolean:
Boolean is a java primitive type. It only accepts true or false (which are declared constants in java).
String:
String is a sequence of characters, for e.g. Hello is a string of 5 characters. In java, string is an immutable object which means it is constant and can cannot be changed once it has been created.
Choice of data types
The noteworthy data is taking after the record of particular data which pointed in others way, and the data type showing to each number of ideal conditions for specific zones with component extent of execution.
Environment
Run time environment
The Java Runtime Environment (JRE), also known as Java Runtime, is part of the Java Development Kit (JDK), a set of programming tools for developing Java applications. It provides the minimum requirements for executing a Java application. It consists of the Java Virtual Machine (JVM), core classes, and supporting files.
Programming Syntax
Command rules
A program’s source code must have correct syntax in order to compile correctly and be made into a program or it will fail to compile and produce a “syntax error.”
Variable declaration
A variable is a container that holds values that are used in a Java program. To be able to use a variable it needs to be declared. Declaring variables is normally the first thing that happens in any program. Java is a specifically programming language. This implies each variable must have an data type connected with it. For instance, a variable could be declared to utilize one of the eight primitive data types: byte, short, int, long, float, double, char or Boolean. A decent similarity for a variable is to think about a container.
Standards
Code layout and indentation
Coding proposal for java incorporates the naming concentrates principally on inspecting issues of layout style code. Code design specifically space style is something of a heavenly war in programming system. The naming convention utilizing parts container and layout oversee classes of the java program. Despite the fact that, it bode well to cover the format director where it likewise say the particularly the objects are includes.
Code indentation is drawing nearer the issue when code layout structure of the code spoke to outwardly as precisely as could be allowed. In this manner, the structure code concentrate on area of block delimiters or opening or shutting the keyword either picked the best outwardly mirror the sensible structure.
Environmental Flexibility of Java
The design requirements of the Java programming language are driven by the nature of the computing environments in which software must be deployed.
The massive growth of the Internet and the World-Wide Web leads us to a completely new way of looking at development and distribution of software. To live in the world of electronic commerce and distribution, Java technology must enable the development of secure, high performance, and highlyrobust applications on multiple platforms in heterogeneous, distributed networks.

Simple, Object Oriented, and Familiar
Primary characteristics of the Java programming language include a simple language that can be programmed without extensive programmer training while being attuned to current software practices. The fundamental concepts of Java technology are grasped quickly; programmers can be productive from the very beginning.
The Java programming language is designed to be object oriented from the ground up. Object technology has finally found its way into the programming mainstream after a gestation period of thirty years. The needs of distributed, client-server based systems coincide with the encapsulated, message-passing paradigms of object-based software. To function within increasingly complex, network-based environments, programming systems must adopt object-oriented concepts. Java technology provides a clean and efficient object-based development platform.
Programmers using the Java programming language can access existing libraries of tested objects that provide functionality ranging from basic data types through I/O and network interfaces to graphical user interface toolkits. These libraries can be extended to provide new behavior.
Even though C++ was rejected as an implementation language, keeping the Java programming language looking like C++ as far as possible results in it being a familiar language, while removing the unnecessary complexities of C++. Having the Java programming language retain many of the object-oriented features and the “look and feel” of C++ means that programmers can migrate easily to the Java platform and be productive quickly.
Robust and Secure
The Java programming language is designed for creating highly reliable software. It provides extensive compile-time checking, followed by a second level of run-time checking. Language features guide programmers towards reliable programming habits.
The memory management model is extremely simple: objects are created with a new operator. There are no explicit programmer-defined pointer data types, no pointer arithmetic, and automatic garbage collection. This simple memory management model eliminates entire classes of programming errors that bedevil C and C++ programmers. You can develop Java code with confidence that the system will find many errors quickly and that major problems won’t lay dormant until after your production code has shipped.
Java technology is designed to operate in distributed environments, which means that security is of paramount importance. With security features designed into the language and run-time system, Java technology lets you construct applications that can’t be invaded from outside. In the network environment, applications written in the Java programming language are secure from intrusion by unauthorized code attempting to get behind the scenes and create viruses or invade file systems.
High Performance
Performance is always a consideration. The Java platform achieves superior performance by adopting a scheme by which the interpreter can run at full speed without needing to check the run-time environment. The automatic garbage collector runs as a low-priority background thread, ensuring a high probability that memory is available when required, leading to better performance. Applications requiring large amounts of compute power can be designed such that compute-intensive sections can be rewritten in native machine code as required and interfaced with the Java platform. In general, users perceive that interactive applications respond quickly even though they’re interpreted.
Interpreted, Threaded, and Dynamic
The Java interpreter can execute Java bytecodes directly on any machine to which the interpreter and run-time system have been ported. In an interpreted platform such as Java technology-based system, the link phase of a program is simple, incremental, and lightweight. You benefit from much faster development cycles–prototyping, experimentation, and rapid development are the normal case, versus the traditional heavyweight compile, link, and test cycles.
Modern network-based applications, such as the HotJava Browser for the World Wide Web, typically need to do several things at the same time. A user working with HotJava Browser can run several animations concurrently while downloading an image and scrolling the page. Java technology’s multithreading capability provides the means to build applications with many concurrent threads of activity. Multithreading thus results in a high degree of interactivity for the end user.
The Java platform supports multithreading at the language level with the addition of sophisticated synchronization primitives: the language library provides the Thread class, and the run-time system provides monitor and condition lock primitives. At the library level, moreover, Java technology’s high-level system libraries have been written to be thread safe: the functionality provided by the libraries is available without conflict to multiple concurrent threads of execution.
While the Java Compiler is strict in its compile-time static checking, the language and run-time system are dynamic in their linking stages. Classes are linked only as needed. New code modules can be linked in on demand from a variety of sources, even from sources across a network. In the case of the Hot Java Browser and similar applications, interactive executable code can be loaded from anywhere, which enables transparent updating of applications. The result is on-line services that constantly evolve; they can remain innovative and fresh, draw more customers, and spur the growth of electronic commerce on the Internet.
My finding for the client
In java programming, it has more applicability than any other language. It can be used in computer embedded system. We find that customers are satisfied with the programmed designed by java language. Designing a program through java language is helpful for everyone. It can reduce time. It is not easy language. We need to be very expert to writing a program in java language. Though it is high level language but it has many things to be an elite language. It has many variable and constant to write a language. We need to be industrious to be good at java language. We find that customers are taking java oriented software undoubtedly.

Conclusion
In my above discussion I have tried to show vivid description of Java programming. I wrote principle of Java programming reason for choosing Java programming, the method of Java, data structure of Java. And through the example and definition I show the various way of Java programing, some frequently asked Java question. In my assigned work I give definition, idea, example, figure and many others way to make my understanding clear. Therefore, it is worth mentioning to say that Java programming is one of the best programming language in computer world. Due lack of time, I was not able to say everything about Java. But, I hope, studying the report, everybody will have enough knowledge of Java. And it is will be a good project to keep record.

Bibliography

 

Source: Essay UK - http://doghouse.net/essays/information-technology/principles-of-java-programming/


Not what you're looking for?

Search our thousands of essays:

Search:


About this resource

This Information Technology essay was submitted to us by a student in order to help you with your studies.



Word count:

This page has approximately words.


Share:


Cite:

If you use part of this page in your own work, you need to provide a citation, as follows:

Essay UK, Principles of Java programming. Available from: <http://doghouse.net/essays/information-technology/principles-of-java-programming/> [21-02-19].


More information:

If you are the original author of this content and no longer wish to have it published on our website then please click on the link below to request removal:


Essay and dissertation help


Latest essays in this category:


Our free essays:

badges