Java 08/04/2021 2:42pm (UTC)


Introduction to Java

1) Java was developed by James Gosling, Patrick Naughton, Chris Warth, Ed Frank, and Mike Sheridan at Sun Microsystems in 1992.
2) The first name of the Java was ‘Oak’, but some of the registration problems it will be renamed as Java (When a Sun People visited a coffee shop and name was suggested) in 1995.
3) Bill Joy, Arthur van Hoff, Jonathan Payne, Frank Yellin, and Tim Lindholm were contributed good efforts to the design and evolution of this language.
4) Sun People think that we need a powerful language for working equaling speed of the
microprocessor and overcome the all disadvantages of early programming languages (i.e.100 percent Plat form independent and maximum utilization of Internet) and
5) They’ll want to largely used Java in large-scale enterprise applications, to enhance the
functionality of WWW servers (Web Browsers) and to provides applications for consumer electronic devices (cell phones, pagers and etc.) and many other uses.

Guide: the object (compiled) of any C++ program (xxx.cpp) was ‘xxx.exe’, which can’t be modifiable because of which is Windows compatibility. But the object of Java program was modifiable. i.e., ....> xxx.class which has the byte code instructions was handled by JVM, which can’t windows compatibility. So that Java was Plat form Independent language.
Learn: Computer System is the combination of Software and Hardware. S/W is a platform on which write the programs to develop a application and H/W all the equipments of the computer.
Learn: Execution Time is combination of Time taken by the user and Time taken by the System.
Learn: Client is a machine to access the resources which provided by the serve and Server is machine which provides services.

Features of Java

• Java was a simple programming language because of it was designed easy for the professional programmers to learn and use effective and efficient manner.
• Java was the Object Oriented: the structure of the program based on the objects and data and functions are treated as single unit.
• Java was a secure language because early download a normal Java program is tedious job reason is virus infections, but if you can safely download Java xs without of fear of viral infections ( Which handle by Part of JVM called as Security manager)
• Java was portable language because for downloading the programs the computers & OS are various type platforms, but the Java was the Platform independent language, so the both efficient and effect for Computers and OS.
• Java was Architecture-Neutral, Write a Java Program Once-it’ll compile & run anywhere & anytime and forever. These are handled by JVM.
• Java was Compile and Interpreter language: After writing the Java Program, we’ll compile using javac.exe i.e., that file in the form of byte code (Which is there in JDK-Java Development Kit) & and run the program using java (JVM).
• Java was Robust (Reliable): Most of the errors taken care at the compile time & the Programmer is not have a privilege to work with the memory addresses & Java run time system handling the exceptions, that program will terminates without affecting the any other resources.
• Java was Multi Threading: More than one Method (Thread) is working in the same memory. By using Multithreading the execution time of the program will reduce and increased the utilization of the CPU.
• Java was Garbage collector: memory will be removed automatically when the object was silent or not used.
• Java was Distributed: Objects on two different computers to execute procedures remotely Using the RMI-Remote Method Invocation i.e., the data is distributed over the network (client-server programming)
• Java is Open Source language and strictly type language and high performance.
Java Fundamentals
1) Java consisting of
• J2SE------Standard Edition
• J2EE-----Enterprise Edition
• J2ME-----Mobile Edition
2) The structure of Java program as shown below

3) Java programming environment / the style of Java program as shown below
Step1: Editor - Created and Stored program in disk with extension of .java

Step2: Compile - It creates bytecodes and stores them in a disk have the extension of .class

Step3: Class Loader - It loads .class file into the memory

Step4: ByteCode Verifier – It confirms bytecode’s are valid and do not violate security.

Step5: Interpereter – reads bytecodes and translates them into a language that can understand by computer.

4) After compiling any Java program, it will converted as Byte code instructions which is understand only by Java Virtual Machine(JVM=Just in Time(JIT) + Interpreter) & converted into machine language instructions. JVM is a set of programs. It comes along with all 32 Bit Operating Systems & it is system dependent. JVM consists of 3 things i.e. 1) Class Loader: helps loads Java program into memory 2) Byte code instructions: converted it into byte code form 3) security verifier: checks the virus infection in the application. The architecture of JVM as shown below

5) Comments in java indicates the aim/logic of the program and the programmer tells about the program to the end users or other programmer. Comments are increased the readability of the programs. A good programmer always mentions the possible comments in the program. There are 3 types of comments exists in java
? Single line comments //---------------
? Multi line comments /*----------------*/
? Documentation comments /**---------------*/

6) Naming conversions in Java are
? Java is case sensitive, all the lower and upper case letters are treated as different.
? Each word of class & interface names start with a Capital letter.
? Package names are in small letters
? Methods and Variables names must start with a lowercase letter and then each word start with a Upper case letter
? Constants name are in Upper letters
7) Java doesn’t have any special won IDE, the program will doing in any DOS editor, Notepad, WordPad, Edit Plus and etc. To do java Program, you want must follow the below things
• After Writing the Java code it will be saved with the extensions of .java
• Compile any Java program using javac programname’
• To run the Java program java programname’s
• If u want see the byte code form java –p programname
• If you want to use packages: java –d .
8) Example:
Step 1 planning a problem: Display the Welcome message
Step 2 Generate the Code for above problem:
Class JavaExample
public static void main(String args[])
System.out.println(“Welcome to My World”);
Step 3 Compile and execute:
C:> java JavaExample //if no compilation errors

) There are 48 keywords exist in the Java language, and these cannot used as names for the variable, class or methods. The keywords are shown below

Reduced: 89% of original size [ 572 x 229 ] - Click to view full image

Guide: ‘#iinclude’ makes the preprocessor to copy the entire header file into the program, so that it increases the size of the program hence takes the more memory and decrease the speed of the execution whereas the ‘import’ doesn’t copy the any code, it helps to locate the compiler to search for the corresponding location of the classes and methods, hence it increases the speed of execution of the program.
Guide: Set path is command to sharing the resources from one directory to another and class path is a command used for sharing the classes presenting any place.
i.e., set path=c:jdkbin;%path%; & set classpath = c:jdklib;

OOPs Concepts

1) Java has the fully Object-Oriented Programming, the structure of the java program based on the objects and the data and functions are treated as the single unit.
2) Class: A class is a concept or blue print i.e., a class is the imaginary.
3) Object: Object is a real instance/implementation of a class, which is existing. A object wants the memory/space.
4) Items (Properties) and Functionalities (Actions) are done in any class….items are used for performing the functionality. Items are represented by the variables and Actions are represented by the methods or functions i.e. Car is the class and Maruti/Esteem are object.
5) We cannot invoke the members with the class name, we must 1) create the objects or 2) extends the class.
6) Features of OOPs:
• Encapsulation: Combing the items and functionalities together as the single unit (Same memory). Reusability of data and methods & efficient way of execution.
• Data Hiding: some object hidden from other objects, DH is the process of secretary the object with the internal and external properties.
• Abstraction: is the process of extracting the necessary details while ignores unnecessary details.
• Inheritance: create the new concept from an already existing concept for the reusability. There are 5 types of Inheritance are exist 1) Simple 2) Hierarchical
• 3) Multilevel 4) Multiple and 5) Hybrid inheritance.
• Polymorphism: Object can be used more than one purpose or same object gives more than one form, which are function overloading and operator overloading.
Learn: Ambiguity error: the compiler cannot take the decisions.

Data Types
Data type indicates that the type of the value/data stored in the memory. It is the concept of declaring the variable to allocate memory to store the constants. To declaring a variable, we must want to mention its data type. There are two types data types in java
1) Primitive Data type: A variable in which only one value can store at a time
• Numeric Data Type
? Integer Data type ( A number without decimal)
o byte (1 byte)
o short (2 bytes)
o int (default data type) (4 bytes)
o long (8 bytes)
? Real/Float Data type ( A number with have decimals)
o Float (4 bytes)
o double (default data type) ( bytes)
• Character Data Type ( to declaring the single character in the variable)
o char (2 bytes)
o String: A String is special library file in java. Lang
• Boolean Data Type (boolean is used for storing the result of the condition)
o boolean true or false
2) Abstract Data type: Using the PDT, we can create the ADT.
Guide: Java is the language taking character from all the international language and additional characters as in form of Unicode character. So char takes the two bytes of memory.
Learn: Initialization is a time of declaring the variable gives the value.
Learn: literal means the value being stored in the variable.
Guide: The storage range of data type was -2(pow,n-1) to + 2(pow,n-1)-1 where n is the number of bits.
Guide: Type casting is the process of converting one data type into similar data type where as parsing is the process of converting one data type to other data type. It may lead the Exceptions.

It is the collection of similar data types storing in the same name and identified with specific index. These elements are storing in 0 to n-1 index. There are three (3) types arrays exist.
1) Single dimensional arrays: it represents single row or column of elements
• creating and declaring single dimensional an arrays:
int arr[]; //declare
arr= new int[10]; //creating
int arr [] =new int [10];
String arr1[]=new String[10],arr2[]=new String[10];
• Initializing single dimensional an array:
int arr [] = {10, 20, 30, 40, 50};
• length (arr.length) is a property of an array is used to find out size of an array.
Learn: new is the operator is used to allocated memory and when we create an array all the location of that array will be initialized with the default values as a result of execution of the default constructor, it is a system define constructor at the time of creating anything with help of new operator.
2) Two or double dimensional arrays: group of row & column of elements
• int a[][]=new int[5][5] //a. length=5 i.e., no of columns only
• float a[][]={ {1.5, 2.5, 3.5}
{1.6, 2.6, 3.6}
{1.7, 2.7, 3.7}
3) Multi dimensional arrays

Command line arguments
Additional parameter or external values are given to the JVM at the time of invoking a class file is known as command line arguments. Command line arguments should be separate with the space (any spaces between the two values are treated as single space) and all command line arguments are string type. The command line arguments are used to run time we can give the inputs to the program. ‘args’ is a method to used to implants all program in command line argument. Such like ‘args[0],arg[1] and etc commands are single parameters & ‘args.length’ is the method to find total arguments. Example of Command line arguments program as shown below i.e. Sum of two numbers using this method
class cla
public static void main(String args[])
int a=Integer.parseInt(args[0]);
int b=Integer.parseInt(args[1]);
int c=a+b;
System.out.println("SUM was " + c);
System.out.println("Invalid no of arguments");
Output of the program:
java cla 10 20
Sum was 30

Working with the class and Object
A class is a keyword and class is an Abstract Data Type (ADT).
• The syntax and example of a class is
Member data’s
Member functions
class classemp
int eno;
String ename;
double sal;
void getdata()
void dispdata()
System.out.println(“EmpNo “ +eno + “EmpName ” + ename + “EmpSal ” + sal);
• Creating an object:
object type object name = new object type(arguments);
classEmp obj= new classEmp(); //here new is used to allocating memory.

Learn: this is the operator is acting as reference of the current object and object memory will get activated when the time of invoking the object.
• Reference Object: Same memory is used
classemp emp1=new classemp()
classemp emp2;

Working with more than one Class
The output of the compilation is based on the number of classes present inside the java program. The program exists n classes then n class byte code files will be created by the java compiler so that it is better to save the program with the name of the class in which the main method is defined.
Guide: the main method can specify more than one time in the program in different classes and each class can have main method.
Exercise: Function Passing an objects and Function returning an objects

Access Specifier

Access Specifier’s from where we can invoke, and there are four basic types of access specifies such as
o public: if the public is specified to anything, class, interface, member data and functions can be invoked from anywhere, even from the sub directory also.
o protected: if this is protected, they can be invoked from within the class or with in the child class only
o private: if it is private, they can be invoked within the class in which it declared.
o default: the default has got more degree of the accessibility that private and less degree of accessibility of that public. It is invoked from within the current package, directory they can’t be invoked from any other sub directories.
Guide: In the java program if there exists any class with the access specifier of public, that program has been saved within the name of pubic class itself and it is not possible to have more then one class with the access specifier as public.

Access Modifier
Access modifier is how it specifies to access something and it will be modified and there are four types of access modifier:
o static:
1) Static members can be invoked without the help of objects, they can be invoked with the help class name itself by using syntax
2) All the static member data will be initialized first. Static member data will be shared by all the objects. Not static members can not be used within the static context.
3) this or super keyword can’t be used within static context.
4) A static block will get executed first before main
Guide: A static member function is invoked with out the help of an object, so that the reference of an object will not come inside a static method, so that the reference of an object this or super can’t be used inside a static member function.
o final: this is used for declaring constant in Java. A constant can not be used changed or assigned. If the member data is declared as final that can’t be changed or assigned. If he member function declared as final that can’t be overriding and the class is declared as final the child classes can’t be created from that from that.


It is a function and name of the function is same as class name, it has no return type. And used for initializing the member data’s. It is automatically call when the object of that class automatically call when the object is used. There are two types constructors
1) default constructor: It is the system defined constructor
2) parameterized constructor: it is the user defined constructor (user given to parameters)
class ConDemo
ConDemo(int x)
void Test()
public static void main(String args[])
ConDemo cd=new ConDemo(100);
ConDemo cd2=new ConDemo();


1) Overloading member functions
In a program there exists more than one function with same name but with different signatures are known as function overloading or function polymorphism. The function calling signature should be matching with the function definition signature.
Learn: the function name together with the argument details is known as function signature and In the program it is not possible with a same signature. Function overloading can be classified as 3 types
1) type of arguments
2) size of arguments
3) sequence no of arguments
Exercise: overloading constructor
2) Operator overloading:
  Menu Items

MCA PROJECT DETAILS ------------------------------------- Jntu all Lab manuals ------------------------------------- Jntu Syllabus Books ------------------------------------- Paper presentations ------------------------------------- Seminars ------------------------------------- Campus Papers ------------------------------------- Competetive Exams GATE ------------------------------------- GRE ------------------------------------- TOEFL ------------------------------------- IELTS ------------------------------------- CAT ------------------------------------- GMAT ------------------------------------- Templates ------------------------------------- Students Resume Preparation tips ------------------------------------- Job zone(Interview questions) ------------------------------------- Google Adsence html code ------------------------------------- Web sites --------x--------------x-----------


  Offline Messages
  Visitors Information
Today, there have been 85538 visitors (230079 hits) on this page!
This website was created for free with Would you also like to have your own website?
Sign up for free