Six Week Summer Training Report: Object Oriented Programming Using Java Course Code-Cse343
Six Week Summer Training Report: Object Oriented Programming Using Java Course Code-Cse343
on
OBJECT ORIENTED PROGRAMMING USING
JAVA
COURSE CODE-CSE343
SUBMITTED BY:-
PRITAM PARIDA
11802180
K18GX
DECLARATION
I hereby declare that I have completed my six weeks summer training on EBOX
platform from April 30,2020 to June 25,2020.I have declare that I have worked full
dedication during the 6 weeks of training and my learning outcomes fulfill the
requirements of training for the award of degree of B.tech. CSE , Lovely
Proffesional University, Phagwara.
2 WHY JAVA? 7
4 Learning Outcome 18
5 Reference 19
INTRODUCTION
All of the above was part of my training during my summer break I specially
choose the JAVA by EBOX for reasons stated below :
OBJECT:-
It is a basic unit of Object Oriented Programming and represents the real life
entities. A typical Java program creates many objects, which as you know, interact
by invoking methods. An object consists of following:
State : It is represented by attributes of an object. It also reflects the properties of
an object.
Behavior : It is represented by methods of an object. It also reflects the response of
an object with other objects.
Identity : It gives a unique name to an object and enables one object to interact with
other objects.
Example of an object : dog
Objects correspond to things found in the real world. For example, a graphics
program may have objects such as “circle”, “square”, “menu”. An online shopping
system might have objects such as “shopping cart”, “customer”, and “product”.
Declaring Objects (Also called instantiating a class)
When an object of a class is created, the class is said to be Instantiated. All the
instances share the attributes and the behavior of the class. But the values of those
attributes, i.e. the state are unique for each object. A single class may have any
number of instances.
COLLECTIONS-I
Almost, In every day scenarios, we handle objects / data in plural form (list or
group of objects). When we model these scenarios in our applications, We need to
define appropriate data structures and harness the existing utility methods available
as part of Java Development Kit (JDK).
There are many collection data structures and its corresponding
class implementations available in Java, like ArrayList.
RELATIONSHIP
In Java, we can reuse our code using an Is-A relationship or using a Has-A
relationship. An Is-A relationship is also known as inheritance and a Has-A
relationship is also known as composition in Java.
Is-A Relationship in Java
In Java, an Is-A relationship depends on inheritance. Further inheritance is of two
types, class inheritance and interface inheritance. It is used for code reusability in
Java. For example, a Potato is a vegetable, a Bus is a vehicle, a Bulb is an electronic
device and so on. One of the properties of inheritance is that inheritance is
unidirectional in nature. Like we can say that a house is a building. But not all
buildings are houses. We can easily determine an Is-A relationship in Java. When
there is an extends or implement keyword in the class declaration in Java, then the
specific class is said to be following the Is-A relationship.
Has-A Relationship in Java
In Java, a Has-A relationship is also known as composition. It is also used for code
reusability in Java. In Java, a Has-A relationship simply means that an instance of
one class has a reference to an instance of another class or an other instance of the
same class. For example, a car has an engine, a dog has a tail and so on. In Java,
there is no such keyword that implements a Has-A relationship. But we mostly use
new keywords to implement a Has-A relationship in Java.
INHERITANCE AND POLYMORPHISM
An abstract class is a class that is declared abstract—it may or may not include
abstract methods. Abstract classes cannot be instantiated, but they can be
subclassed.
An abstract method is a method that is declared without an implementation
(without braces, and followed by a semicolon), like this:
abstract void moveTo(double deltaX, double deltaY);
If a class includes abstract methods, then the class itself must be declared
abstract, as in:
Strings, which are widely used in Java programming, are a sequence of characters.
In Java programming language, strings are treated as objects.
The Java platform provides the String class to create and manipulate strings.
Creating Strings
The most direct way to create a string is to write −
String_Greeting = “Hello World!”;
Whenever it encounters a string literal in your code, the compiler creates a String
object with its value in this case, "Hello world!'.
As with any other object, you can create String objects by using the new keyword
and a constructor. The String class has 11 constructors that allow you to provide the
initial value of the string using different sources, such as an array of characters.
EXCEPTION HANDLING
The Exception Handling in Java is one of the powerful mechanism to handle the
runtime errors so that normal flow of the application can be maintained. There are
mainly two types of exceptions: checked and unchecked. Here, an error is
considered as the unchecked exception. According to Oracle, there are three types
of exceptions:
1) Checked Exception
The classes which directly inherit Throwable class except RuntimeException and
Error are known as checked exceptions e.g. IOException, SQLException etc.
Checked exceptions are checked at compile-time.
2) Unchecked Exception
The classes which inherit RuntimeException are known as unchecked exceptions
e.g. ArithmeticException, NullPointerException,
ArrayIndexOutOfBoundsException etc. Unchecked exceptions are not checked at
compile-time, but they are checked at runtime.
3) Error
Error is irrecoverable e.g. OutOfMemoryError, VirtualMachineError,
AssertionError etc.
MULTITHREADING
LEARNING OUTCOMES
On completion of the course I was able to:
EBOX(COURSE)