Turn Desktop View Off
by Dinesh Thakur Category: Introduction to Java

The objects in our programs exist only while the program is executing. When the program closed, these objects cease to exist. How can we save an object in our program and restore it when the program rerun? For example, suppose that we are playing a computer chess game. We close the game before it finished. When we restart the game, it should resume from where we had left it, instead of from the beginning. One way to accomplish this would be to save information about the game (such as the locations of various game pieces, scores, and so forth) to a file, and then read this information back from the file to restore the game to the state where we had left it when it runs next. This is the idea behind serialization. Serialization is saving an object's state as a binary stream (that is, as a sequence of bytes). When an object is serialized, it is said to be flattened or deflated. The reverse process of constructing an object from the binary data is known as deserialization. Thus, a deserialised (or inflated) object is one whose state has restored.



 
by Dinesh Thakur Category: Introduction to Java

In Java 1.5, a new class known as Scanner class was introduced to simplify the task of getting input from the user. The Scanner class is in java.util package which allows the user to read the data dynamically from the keyboard. It can be used to read a File on the disk. The Java Scanner class extends Object class is present in java.lang package and implements Iterator and Closeable interfaces.



 
by Dinesh Thakur Category: Introduction to Java

Immutable class means unmodifiable or unchangeable, i.e., once the object has been created, they are immutable objects, there is no way to modify the text it represents. In Java, all primitive java.lang package wrapper classes (like String, Boolean, Byte, Short, Integer, Long, Float, Double, etc.) and String classes are immutable.



 
by Dinesh Thakur Category: Introduction to Java

In this section, we will see the implementation of a simplified version of linked list class provided by the Java library. This shows how the lists of operations manipulate the links when the list is modified.

 
by Dinesh Thakur Category: Introduction to Java

You've probably used a computer for work or leisure. Many people use computers for everyday tasks such as check the bank balance or write a school report. Computers are good for these tasks. They can treat repetitive tasks, such as adding numbers or insert words on a page without getting bored or exhausted. Computers are also good for games because they can play sequences of sounds and images, involving the human user in the process.



 
by Dinesh Thakur Category: Introduction to Java

The RMI architecture, shown in Figure, describes how remote objects behave and how parameters are passed between remote methods. Remote method invocation allows the program to define separately the behaviour and the code that implements the behaviour and allows running them on separate JVMs. This principle facilitates the clients to focus on the definition of a service while the servers can focus on providing the service.

 
by Dinesh Thakur Category: Introduction to Java

The Java RMI comes along with Java JDK l.l and higher versions. It is a true distributed computing application interface for Java. Java RMI is language-specific, and can provide more advanced features like serialization, security and so on.

 
by Dinesh Thakur Category: Introduction to Java

Applet: A small program for specific functions, which usually come with the operating system. Examples in Windows are Paint and Notepad. On a Macintosh, examples are Calculator and Scrapbook. The name comes from the term "applications" which is one variety of a software program.



 
by Dinesh Thakur Category: Introduction to Java

We will now make a small program that will input two integers in Java and display their sum. In this program, we will use the methods available in Scanner class to read data typed at keyboard and place it into variables that we specify.



 
by Dinesh Thakur Category: Introduction to Java

Our first program is composed of three logical parts :

1. Definition of the class;
2. Definition of the method main ();
3. Content of the method main ().

 
by Dinesh Thakur Category: Introduction to Java

A Java class is a group of Java objects all of which have the same or similar properties in common. Classes are logical entities and can never be physical. In a class  you may find:  
● Fields  
● Methods  
● Constructors  
● Blocks  
● Nested classes and an interface

In the Following Java Example, shows how to Create a Class Using Java Example. in this example we show that Syntax of java object creation is <className> objectName = new <classConstructor>; and the Syntax of defining methods of the java class is <modifier> <return-type> method-Name(<optionalParameterList>) <ExceptionList>



 
by Dinesh Thakur Category: Introduction to Java

In this Example we Reading amount, Year and interest in the class Scanner becomes analogous to reading string. In this example, the three numbers are read from the console, and then perform Simple Interest,Compound Interest operations and results printed on the screen in formatted output.

 
by Dinesh Thakur Category: Introduction to Java

In this Example we Reading the numbers and string in the class Scanner becomes analogous to reading string. In this example, the two numbers are read from the console, results printed on the screen formatted output.

 
by Dinesh Thakur Category: Introduction to Java

Java program has two types. They are:

 

1. Application Program (Stand-alone application)

2. Applets Program.

 
by Dinesh Thakur Category: Introduction to Java

The first step of compiling and running a Java program is to write the text of your program in a document and save it on the hard drive. This document is called a source file, and you must name it with a .java extension. Next, compile this program using a Java compiler. The compiler checks the program for errors and, if no errors are found, it generates a new document containing Java bytecode. This document is called a class file, and its name ends with a .class extension.



 
by Dinesh Thakur Category: Introduction to Java

The different languages reflect the different styles of programming. OOP or object-oriented programming is a style of programming with a firm basis in several concepts. Those concepts revolve around objects and classes and include Polymorphism, Encapsulation, Inheritance, Abstraction and more.  Java is one of the most popular of all the object-oriented programming languages, as well as one of the easiest to learn and use.   
Any application built on objects in Java is an object-oriented application and is based on the declaration of one or more classes, with an object created from those classes and the interaction between the objects.    

 
by Dinesh Thakur Category: Introduction to Java

Public keyword is an access specifier.

Static allows main() to be called without having to instantiate a particular instance of class.

 
by Dinesh Thakur Category: Introduction to Java

Modifiers are keywords used to define the scope and behaviour of classes, methods and variables in Java. Access modifiers specified who can access them. Java has a wide variety of modifiers that can be categorized as shown below:

 

Page 1 of 2



About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.