Any opinions, findings, conclusions or recommendations expressed in this material are those of the authors and do not necessarily reflect the views of UKEssays.com.
Programming languages play the most important role in the creation of various Software’s. Application, and Webpages etc. Just because of the existence of programming languages today everything related to New Technology is possible. For example the various Social Networking sites that we use is a result of Programming Language, the Mobile phones that we use in our daily life is a brilliant outcome of programming as every IC in the circuit of the mobile phones are programmed due to which it works.
The most important outcome of Programming Language is the creation of Operating Systems (OS). OS is something without which we cannot use our PC’s or Laptop’s or even our mobile phones. OS acts as a base for every single function of a device to work in short it provides an important platform for the working.
If no programming languages were introduced then today it nearly impossible for the people to use computers, mobile phones, servers, and various other things. But thanks to the developers of the various types of Languages that made peoples life very easy and mobile.
All about JAVA!
Java was developed by James Gosling at Sun Microsystems in 1992 and was officially released in 1995. JAVA Technology is a programming language that is used for meeting the objectives of current challenges and opportunities in the present computing realm.
Java Virtual Machine (JVM): JVM is an Interpreter for JAVA programming language, i.e., it is the only way to convert a Byte Code into machine language. The Byte Code cannot be converted using any technique other than the JVM. Therefore as I said above Byte Code somehow helps Java in being secure.
Java Runtime Environment (JRE): We all know that that the major problem with the programming languages before JAVA was platform dependency i.e., if we want to run the code compiled in Windows Xp in Linux, this was not possible as for that we need a special compiler which works in Linux only. So to solve this problem JRE was launched and became a part of java. Every Operating System have some mandatory files that are needed to run java on that particular OS. So in short JRE in the collection of all those mandatory files needed to run java on various OS’s plus JVM.
Due to JRE today it is possible to use the code written in some OS in any other OS.
So JRE made JAVA completely PLATFORM INDEPENDENT.
The byte code is loaded into JVM using the Class Loader.
JIT (Just in Time): JIT works as a verifier. It verifies the Byte Code first whether it is infected or not or whether it is holding some kind of virus in it or not. If found clean it forwards the Byte Code to the JVM for further process.
JIT is completely responsible for the SECURITY of JAVA.
Let’s see the whole process graphically.
Now I’ll show you a basic program in java with its output.
public static void main(String…s)
Let’s talk about the main() function.
The main function is made up of 5 things.
Access Specifier Function Name
public static void main() Parentheses
Access Modifier Return Type
All programming languages have its own syntax and reserved keywords. JAVA also has these kind of language fundamentals.
Basic fundamentals of java includes:
- Java Keywords
- Data Types
- Legal and Illegal Identifiers
Let’s see every fundamental in detail.
- Java Keywords: Keywords are the words that convey special meaning to the language compiler. These are reserved for special purposes and must not be used as normal identifier names.
- Data Types: Data types are keywords are means to identify the type of data and how much memory a variable needs to carry out a particular operation.
Data types are divided into two types:
- Primitive Data Types (8 types)
- Non Primitive Data Types (User Defined 3 types)
- Legal and Illegal Identifiers: Identifiers are building blocks of a program and are used as the general terminology for the names given to different parts of the program viz. variables, objects, classes, function, arrays etc.
- Operators: The operations being carried out are represented by operators. The operations (specific tasks) are represented by operators and the objects of the operation are referred as operands
Classes in JAVA
Class is a collection of objects of similar types of objects. Objects are nothing but a buffer or an area and are defined by something which have some property and behaviour.
In java objects are created in the HEAP Memory inside the Java Virtual Machine.
Syntax for creating an object in java:
Class name object name=new class name();
new is a keyword of java which when used creates an object in the HEAP. Now whenever we use the new keyword a space in created in the HEAP memory inside the JVM for the object at runtime.
When we print the reference variable of some class then it prints 3 things:
- Class name
- “@” symbol
- Hash code
Graphical representation of HEAP and other memory areas available inside the JVM.
Principal of Object Oriented Programming (OOP)
The object oriented programming has been developed with a view to overcome the draw backs of conventional programming approaches. The OOP approach is based on certain concepts that helps it to attain its goal of overcoming the drawbacks of conventional programming approaches. There are 4 general concepts of OOP:
- Encapsulation (it’s a part of abstraction)
- Polymorphism: It is the ability for a message or data to be processed in more than one form or it can simply be defined as one name used for many tasks which is used to speed up the compilation time.
- Inheritance: This is a parent-child relationship between two classes. In this, the child class object inherits some properties of the parent class object.
Abstraction refers to the act of representing essential features without including the
background details or explanations.
Abstraction is divided into two parts:
- Abstract Class: Abstract class is used to define a rule.
Rules in abstract class:
- All the task which we can perform in a normal java class can also be performed in an abstract class.
- In abstract class we can define normal method as well as abstract methods.
- It is not compulsory to have at least one abstract method in a class.
- If a method is abstract then the class should be abstract.
- We cannot instantiate (cannot create the object) of abstract class.
- Abstraction is achieved using extends keyword.
- Interfaces: Interface are pure abstract methods. A class implements an interface, thus inheriting the abstract methods of an interface. An interface contains the behaviour that the class implements. The class that implements interface is abstract.
declaration of methods;}
Rules in Interface:
- We cannot instantiate of an interface.
- Interface are used to define the rules purely.
- All the methods of an interface are by default public and abstract.
- In case of interface we use the keyword implements.
- If we define any data member inside an interface than by default it becomes static
- Interface is used to achieve Multiple Inheritance.
Packages is a collection of classes and interfaces. No class can exist without a package included in it. This is the rule of OOP’s. But when we open a class we don’t always make a package in that class, so in this case the rule of OOP’s is violated. So to avoid this problem JAVA has given a feature in its compiler due to which when we compile the program, the compiler automatically creates a package of the respective class during the compile time.
Command to compile the program with a package:
javac –d . p.java Name of the project
current directory is the same location as the class where the package is to be made.
Destination. –d . is called the switching tool.
Program with a package can be executed by using the Command:
When any abnormal condition that comes in a code which can be handled then that situation is known as Exception Handling.
For every exception there are exception classes and exception methods to handle that exception in java by default.
We can easily handle these unwanted exceptions by using try and catch block.
Try is used to detect exceptions in a program and catch is used to handle that
The “finally” block: If an exception occurs in a program then the try and catch block will be executed and then the program terminates in normal condition. But in case of finally before the termination of program finally block also executes.
Every process is divided into two categories:
- Heavy Weight Processes
- Light Weight Processes
Heavy Weight Processes: These processes are those processes which stores a separate
area in RAM.
Light Weight Processes: These processes are those processes which occupy memory
under the heavy weight processes.
These light weight processes which occupy memory under the heavy weight processes
are known as Threads in JAVA.
Basically there are two ways in which we can make a thread:
- By directly implementing the runnable interface.
- By internally implementing the thread class in interface runnable and extending thread class.
Every part of a program is called a thread and every thread defines a separate path of execution.
Java provides a building support for multithreading program. The multithreaded program contains two or more parts that execute concurrently.
Priority of which thread will start working first is decided by a program named as Thread Scheduler which is a program of the Operating System. It gives the priority randomly.
To avoid the corruption of data we use the concept of synchronization in threads.
When we share a single object into multiple threads then the chance of data Corruption arises and to avoid this we need the concept of synchronization.
The keyword synchronized is applied on the function where the variables are assigned values. Due to the concept of synchronization only one thread executes at a time.
Streams are nothing but a special type of buffer. In terms of JAVA streams are flow of bytes.
Benefits of I/O Stream:
- Execution time reduces.
- Performance Enhances.
- Network congestion chances reduces.
- We get bulk data at a time.
Streams are divided into two types:
- High Level Stream
- Low Level Stream
High level stream cannot be used alone, whenever we want to use a high level stream we have to connect it by a low level stream.
Byte Stream Character Stream
Console Based Unicode
Input Output Reader Writer
Input Stream Output Stream
- FileInputStream FileOutputStream
- BufferedInputStream BufferedOutputStream
- DataInputStream DataOutputStream
- ObjectInputStream ObjectOutputStream
- ByteArrayInputStream ByteArrayOutputStream
- PipedInputStream PipedOutputStream
- File Reader File Writer
- Buffered Reader Buffered Writer
public static void main(String args)
FileOutputStream fout=new FileOutputStream(“a.txt”);
PrintStream ps=new PrintStream(fout);
This is a sample program of how to write a file by coding in JAVA.
Serialization is the process using which we can convert an object into a stream. If we have to use an object only once and then we need to use the same object after a long time then we use the concept of serialization.
Features of Serialization:
- Only the object of that class can persist which implements serializable interface.
- If the parent class implements serializable interface then there is no need for child class to implement serializable.
- In case of serialization transient data members cannot persist.
- In case of serialization static data members cannot persist.
- Only the non-static data members can persist.
If we make any variable transient that means those variables are unwanted now and will get no memory in the HEAP inside the JVM.
Serializable interface is a type of marker interface. Marker interface are those interface which have no methods.
Cite This Work
To export a reference to this article please select a referencing stye below:
Related ServicesView all
DMCA / Removal Request
If you are the original writer of this essay and no longer wish to have your work published on the UKDiss.com website then please: