Asath Final Jva RP
Asath Final Jva RP
INTERNSHIP REPORT
Submitted by
ASATH K [717823L204]
BACHELOR OF ENGINEERING
IN
.………………………
(Internal Examiner)
INTERNSHIP CERTIFICATE
ACKNOWLEDGEMENT
approach. He has offered incessant help in all possible ways from the
beginning.
internship
TABLE OF CONTENT
CHAPTER NO TITLE
ABSTRACT
LIST OF FIGURES
1 INTRODUCTION
2 DISCUSSION
3 CONCLUSION
4 REFERENCE
ABSTRACT
This abstract introduces a structured and comprehensive Java internship program
designed to equip participants with essential skills in software development using
Java. The internship cover foundational to advanced topics essential for building
robust and scalable applications.
The internship begins with an exploration of identifiers and primitive data types,
where participants learn about naming conventions and fundamental data types
such as int, float, and char. This foundational knowledge sets the stage for
understanding memory allocation and basic data operations in Java.
Participants will then dive into structured data types, focusing on arrays and the
use of classes and objects to organize and manipulate data effectively. Practical
exercises will demonstrate how to implement and utilize these data structures in
real-world scenarios.
Blocks and exception handling are critical aspects of reliable Java programming.
Participants will learn to structure code using blocks, handle exceptions using
try-catch blocks, and implement error management strategies to ensure robust
application behavior under various conditions.
Control structures form the backbone of program logic in Java. Participants will
master conditional statements (if-else, switch), iterative structures (for, while, do-
while), and control flow mechanisms to effectively manage program execution
and decision-making processes.
The internship will also cover procedures and functions in Java, emphasizing
method declaration, parameter passing, return types, and method invocation.
Participants will understand the benefits of modular programming and practice
creating reusable code components through function abstraction.
Inheritance and its role in Java will be explored in depth, focusing on how classes
inherit properties and behaviors from parent classes. Participants will gain
practical experience in method overriding and using class hierarchies to model
complex relationships in software design.
The internship will also introduce inner classes as a means of organizing classes
within other classes, including member classes, local classes, and anonymous
classes. Participants will explore how inner classes enhance encapsulation and
facilitate cleaner code organization in Java projects.
By the conclusion of the Java internship program, participants will have acquired
a solid foundation in Java programming, equipped with practical skills and
industry-relevant experience to pursue entry-level roles in software development
or advance their academic pursuits.
LIST OF FIGURES
17 / 06/ 2024
2
Monday Basic Syntax and Data Types in Java
.
18 / 06/ 2024 Tuesday Variables, Operators, and Control Structures in Java
19 / 06/ 2024
A Wednesday Introduction to Java Classes and Objects
b
o
20 / 06/ 2024 Thursday Creating and Using Java Methods
2.1History of JAVA
Java, developed by Sun Microsystems (which was later acquired
by Oracle Corporation), emerged in the early 1990s as a programming
language with a specific goal: to be platform-independent and portable. Its
history is rooted in addressing the challenges faced by software developers
due to the proliferation of different types of hardware and operating
systems.
The origins of Java can be traced back to a project initiated by James Gosling, Patrick
Naughton, and Mike Sheridan at Sun Microsystems in 1991. Initially named "Oak," the
project aimed to develop software for consumer electronic devices such as set-top
boxes. The primary challenge they encountered was the variety of hardware platforms
and operating systems, which made software development and deployment
cumbersome and costly.
Java introduced several groundbreaking features that set it apart from its predecessors:
Java’s open design and community-driven development approach played a crucial role
in its rapid adoption. The establishment of the Java Community Process (JCP) in 1998
formalized the involvement of developers, organizations, and industry experts in
shaping the future direction of Java. This collaborative effort ensured that Java evolved
to meet the evolving needs of the software development industry.
Java Today
Today, Java remains one of the most widely used programming languages globally. It
powers a diverse range of applications, including enterprise software, mobile
applications (Android), web applications, and embedded systems. Its versatility,
performance, and strong ecosystem of tools and frameworks continue to make it a
preferred choice for developers and organizations across various industries.
Identifiers Java does not restrict the lengths of identifiers. Although the language
does allow the use of a “_” to be included in identifier names, the emerging style is to use
a mixture of upper and lower case characters. The following are example identifiers
exampleNameInJava
example_name_in_Java
Note that the assignment operator is “=” and that comments are delimited by “/*” and
“*/”. Java also allows “//” for comments ending a line.
2.5 structured data types
Java supports arrays; both single and multi dimensional arrays can be created;
for example:
class Date {
int day, month, year;
}
Date birthDate = new Date();
birthate.day = 31;
birthDate.month = 1;
birthDate.year = 2000;
It is not possible to express range constraints on the values of the date's components.
Note also that as a “record” is a class, an allocator (the new operator) must be used to
create an instance of the Date. Initialization of the object can be achieved using con-
structors (see Section 7).
Important note:
All objects created by the new operator are stored in an
area of memory called the heap. An activity called garbage
collection will free up any associated memory when the
object is no longer referenced.
2.6 Reference types
All objects in Java are references to the actual locations containing the
encapsulated data, hence no additional access or pointer type is required.
Furthermore, no forward declaration is required. For example:
class
n be used even though
N // its declaration has not been completed yet.
o }
d
Notee that as a result of representing objects as reference values,
comparing two objects is a comparison between their references
not {their values. Hence,
i
Noden ref1=newNode();Node
ref2t = new Node();
...
v
if(ref1
a == ref2) { ... }
willl compare the locations of the objects not the values
u
encapsulated
e by the objects (in this case, the values of the value and
next; fields). To compare values requires a class to implement an
explicit equals method. A similar situation occurs with object
N
assignment. The assignment operator assigns to the reference. To
o
create
d an actual copy of an object requires the class to provide
methods
e to clonethe object.
n
e
x
t
;
/
/
T
h
e
t
y
p
e
n
o
d
e
c
a
2.7 Blocks and exception handling
In Java, a block (or compound statement) is delimited by “{“ and “}”, and
usually has the following structure
{
< declarative part >
try {
//code that might throw an exception
} catch (Exception err) {
// Exception caught, print error message on
// the standard output. System.out.println(err.getMessage());
}
The catch statement is like a function declaration, the parameter of which
identifies the exception type to be caught. Inside the handler, the object name
behaves like a local variable. A handler with parameter type T will catch a
thrown object of type E if:
• T and E are the same type,
• or T is a parent (super) class of E at the throw point.
It is this last point that integrates the exception handling facility with the
object-ori- ented programming model. In the above example the Exception
class is the root class of all application exceptions. Hence, the catch clause
will catch all application exceptions. Here, getMessage is a method declared in
the Exception class. A call to E.getMessage will execute the appropriate routine
for the type of object thrown. If no exception handler is found in the calling
context of a function, the calling context is terminated and a handler is
sought in its calling context. Hence, Java supports
exception propagation.
Finally clauses
Java also supports a finally clause as part of a try statement. The code attached to this clause
is guaranteed to execute whatever happens in the try statement irrespective
of whether exceptions are thrown, caught, propagated or, indeed, even if there are no
exceptions thrown at all.
try {
...
} catch(...) {
...
} finally {
// code that will be executed under all circumstances
}
Throwable
Error Exception
RunTimeException InterruptedException
IllegalMonitorStateException IllegalThreadStateException
Checked
unchecked
Throughout this book, the term Java exception is used to denote any class derived from
Exception. Objects derived from Error describe internal errors and resource exhaustion in
the Java run-time support system. Although these errors clearly have a major impact on the
program, there is little that the program can do when they are
thrown (raised) as no assumptions can be made concerning the integrity of the system.
Objects derived from the Exception hierarchy represent errors that programs can handle or
can throw themselves. RuntimeExceptions are those exceptions that are raised by the run-
time system as a result of a program error. They include errors such as those resulting from
a bad cast (ClassCastException), array bounds error (IndexOutOfBoundException), a null
pointer access (NullPointerExcep-tion), integer divide by zero (ArithmeticException) etc.
Throwable objects which are derived from Error or RuntimeExceptionsare called unchecked
exceptions, the others are termed checked exceptions. Checked exceptions must be
declared by the function that can throw them. The compiler will check that an appropriate
handler can be found. The compiler makes no attempt to ensure that handlers for
unchecked exceptions exist.
2.8 Control structures
Control structures can be grouped together into three categories: sequences, decisions
and loops.
Sequence structures
Most languages implicitly require sequential execution, and no specific control struc- ture
is provided. The definitions of a block in Java indicate that between { and } there is a
sequence of statements. Execution is required to follow this sequence.
Decision structures
The most common form of decision structure is the ifstatement; for example:
if(A != 0) {
if(B/A > 10) {
high = 1;
} else { high = 0;
}
}
In general, a multiway decision can be more explicitly stated and efficiently imple-
mented, using a switchstructure.
switch(command) {
case 'A' :
case 'a' : action1(); break; /* A or a */
case 't' : action2(); break;case 'e' : action3();
break;case 'x' :
case 'y' :
case 'z' : action4(); break; /* x, y or z */
default : /* no action */
}
As with C and C++, it is necessary to insert statements to break out of the switch once the
required command has been identified. Without these, control continues to the next option
(as with the case of A).
Loop (iteration) structures
Java supports the usual for and while statements. The following example illustrates the for
statement; the code assigns into the first ten elements of array, A, the value of their positions
in the array:
while(<expression>) {
/* Expression evaluating to true or false. */
/* False implies loop termination. */
<sequence of statements>
}
Java also supports a variant where the test occurs at the end of the
loop:
do {
< sequence of statements>
} while (<expression>);
while(true) {
...
if(<expression1>) break;
if(<expression2>) continue;
...
}
2.9 Procedures and functions
Procedures and functions can only be declared in the context of a class, they are known
collectively as methods. In fact, strictly Java only supports functions; a procedure is
considered to be a function with no return value (indicated by void in the function
definition).
Java passes primitive data type (int, boolean, float etc.) parameters (often called
arguments) by value. Variables of class type are reference variables. Hence, when they are
passed as arguments they are copied, but the effect is as if the object was passed by reference.
Consider a function that calculates the roots of a quadratic equation
Function bodies
The bodies of functions are illustrated by completing the quadratic definitions given
above.
class Date {
int day, month, year;
}
This example only illustrates how data items can be grouped together. The
full facilities of a class allow the data items (or instance variables or fields as
Java calls them) to be encapsulated and, hence, abstract data types to be
defined. As an example, consider the class for a queue abstraction.
First, a package to contain the queue can be declared (if there is no
named pack- age, then the system assumes an unnamed package). Items
from other packages can be imported. Then classes to be declared inside the
package are given. One of these classes Queue is declared as public, and it is
only this that can be accessed outside the package. The keyword public is
termed a modifier in Java, the other ones for classes include abstract and final.
An abstract class is one from which no objects can be created. Hence, the class
has to be extended (to produce a subclass) and that subclass made non-
abstract before objects can exist. A final modifier indicates that the class
cannot be subclassed. No modifier indicates that the class is only accessi- ble
within the package. A class can have more than one modifier but certain
combina- tions, such as abstractand final, are meaningless.
Each class can declare local instance variables (or fields), constructor methods
and ordinary (member) methods. A static field is a class-wide field and is shared between
all instances of the owning class. The field is accessible even if there are no
instances of the class. Constructor methods have the same name as their associated class.
An appropriate constructor method is automatically called when objects of the class are
created. All methods of the object can also have associated modifiers. These dictate the
accessibility of the method; public, protected and private are allowed. Public methods allow
full access, protected allows access only from within the same package or from with a
subclass of the defining class and private allows access only from within the defining class.
Instance variables can also have these modifiers. If no modifier is given, the access is
restricted to the package. Static methods (class-wide methods) can be invoked without
reference to an object. They, therefore, can only access static fields or other static methods.
Member methods and instance variables can have other modifiers which
will be introduced throughout this book.
The code for the Queue class can now be given.
else {
back.next = newNode;
}
back = newNode;
}
public Element remove() { //visible method
ifempty()) {
Element
tmp= front.data;
front = front.next; if(empty())
back = null;
return tmpE;
}
// Garbage collection will free up the QueueNode
// object which is now dangling.
return null; // queue empty
}
public boolean empty() { // visible method
return (front == null);
}
private QueueNode front, back; // instance variables
}
Java 1.5 has introduced extra facilities for generic programming. The above
example assumed that the queue was for the Element class. To generalise this
class so that it deals with any element, the Element is defined as a generic
parameter:
CONCLUSION
Throughout this internship, I have explored various aspects of Java
programming language, from its foundational concepts to advanced
object-oriented principles. Starting with an exploration of Java's
origins and evolution, we traced its journey from a language
designed for embedded systems to its current ubiquitous role in
enterprise software development. Key features such as identifiers,
primitive data types, and structured data types were essential in
understanding Java's syntax and data handling capabilities.
Moving forward, we delved into more advanced topics like
reference types, exception handling, and control structures, which
are crucial for building robust and error-resilient applications.
Procedures, functions, object-oriented programming paradigms, and
the concept of packages and classes provided a deeper insight into
Java's modular and scalable approach to software development.
In conclusion, this internship has not only equipped me with
practical Java programming skills but also deepened my
understanding of software development principles. I look forward
to applying these skills in future projects and continuing to explore
the dynamic field of Java development.
CHAPTER 4
REFERENCES
ensure to include proper references to the sources you consulted
during your research. These might include textbooks, online
resources, official Java documentation, and any other relevant
materials that helped you understand and implement Java concepts
effectively.
1. Herbert Schildt. "Java: The Complete Reference, Eleventh
Edition". McGraw-Hill Education, 2018.
Oracle Corporation. "The Java Tutorials". Available online:
https://docs.oracle.com/javase/tutorial