Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 13

SAL EDUCATION

SAL ENGINEERING AND TECHNICAL INSTITUTE


Opp. Science city, Sola-Bhadaj Road, Ahmedabad, Gujarat 380060 Ph:
- 079 67129000 Website: www.sal.edu.in

Student’s Weekly Report of Internship

Student Name: Sureja Krushnakumar Ashokbhai


Enrollment Number: 211260131513
Name Of Organization: Datacrops

External Guide Name: Chetan Parmar


External Guide Contact details: Email: Chetan.parmar@datacrops.com
Mobile No. : 9173771158

Internal Faculty Guide Name: Ravi Patel

Work done in last Week with description (Attach supporting Documents Like
Diagram, Data Dictionary, Screen Shot of each Work):
1. Understand and apply the four fundamental OOP concepts in Java.
2. Develop simple Java programs that demonstrate the use of classes, objects,
inheritance, polymorphism, and abstraction.
3. Learn about access modifiers and their role in encapsulation.

Plans for next week:

Total Working Hrs: ____40__________ Signature of Student:


The above entries are correct and the grading of work done by Trainee is
Excellent Very Good Good Fair Below Average Poor

Signature of External Guide with Company Seal: Signature of Internal Guide

Date: Date:
Encapsulation and Classes:

What is Encapsulation?

Encapsulation is a programming technique that bundles data with the methods that operate on it. It
can also limit direct access to some data, such as an object's components. Encapsulation can be used
to hide the state or values of a structured data object inside a class. It can also prevent external code
from being concerned with the internal workings of an object.

Importance of data hiding Use of getters and setters?

Data hiding is when data is hidden so it will be safe from accidental manipulation. A programmer
uses hiding data to put it in a class and make it private so that it can't be accessed mistakenly by
functions outside the class.
Getters and setters are used to protect your data, particularly when creating classes. For each
instance variable, a getter method returns its value while a setter method sets or updates its
value. Given this, getters and setters are also known as accessors and mutators, respectively.
Inheritance:
Basics of Inheritance and it’s types?

Inheritance is a feature of object-oriented programming (OOP) that allows a class to inherit the
properties and methods of another class. This is useful for creating new classes that are similar to
existing classes, but with some modifications.

There are four main types of inheritance in Java:

 Single inheritance: A class can inherit from only one parent class.

 Multilevel inheritance: A class can inherit from another class, which itself inherits from a
third class, and so on.

 Hierarchical inheritance: A class can have multiple child classes.

 Hybrid inheritance: A class can inherit from multiple parent classes.

The ‘extends’ keyword:

The ‘extends’ keyword in Java is used to create a subclass (child class) that inherits the properties and
methods of another class (parent class). This is known as inheritance. The subclass can then add its
own unique properties and methods.

Method overriding:

Method overriding in Java is a feature that allows a subclass to provide a specific implementation of
a method that is already provided by one of its super classes. This allows the subclass to inherit the
methods of the superclass and modify them as needed.

To override a method, the subclass must declare a method with the same name, return type, and
parameter list as the method in the superclass. The @Override annotation is used to indicate that
the method is overriding a method in the superclass.

The super keyword:

The super keyword refers to superclass (parent) objects. It is used to call superclass methods, and to
access the superclass constructor. The most common use of the super keyword is to eliminate the
confusion between super classes and subclasses that have methods with the same name.
Polymorphism:

Static (compile-time) vs. Dynamic (runtime) Polymorphism:

Difference Between Method Overloading and Method Overriding in Java:


Abstraction:

Abstract classes and methods:

Abstract class

 An abstract class is a class that is declared with the abstract keyword.

 An abstract class cannot be instantiated.

 An abstract class can have abstract and non-abstract methods.

 Abstract methods are declared without an implementation.

 Subclasses of an abstract class must provide implementations for all of the abstract methods
in the parent class.

 Abstract classes are used to provide a common definition for a set of related classes.

 Abstract classes can be used to achieve abstraction in Java.

Abstract method

 An abstract method is a method that is declared without an implementation.

 Abstract methods are declared with the abstract keyword.

 Abstract methods can only be declared in abstract classes.

 Subclasses of an abstract class must provide implementations for all of the abstract methods
in the parent class.

 Abstract methods are used to provide a common definition for a set of related methods.

 Abstract methods can be used to achieve abstraction in Java.


Interfaces:

 An interface in Java is a blueprint of a class. It has static constants and abstract methods. The
interface doesn't contain any instance variables or method bodies; it only specifies the
methods that a class must implement.
 Interfaces are used to achieve abstraction. For example, you can create an interface called
Drawable that specifies the methods that a class must implement to be drawn on the
screen. Any class that implements the Drawable interface must implement the draw()
method.
 Interfaces are also used to achieve polymorphism. For example, you can create a List
interface that specifies the methods that a class must implement to be a list. Any class that
implements the List interface can be used as a list, regardless of its concrete type.

Differences between abstract classes and interfaces:


Access Modifiers and Constructors:

Java Access Modifiers:

 Java access modifiers control the accessibility of fields, methods, classes, and
interfaces. There are four access modifiers in Java:
 Private: The most restrictive access modifier. Private members are only accessible within the
class in which they are declared.
 Default: Also known as package-private. Default members are accessible within the same
package, but not from outside the package.
 Protected: Protected members are accessible within the same package and by subclasses in
other packages.
 Public: The least restrictive access modifier. Public members are accessible from anywhere.

Constructors in Java:

A constructor in Java is a special method that is used to initialize objects. It is invoked at the time of
object creation and is used to set the initial values of the object's fields.
Constructors are similar to methods in that they can have parameters and can perform any valid Java
code. However, there are some key differences between constructors and methods:

 Constructors must have the same name as the class they are in.
 Constructors do not have a return type.
 Constructors are invoked automatically when an object is created, using
the new keyword.

The role of constructors in OOP, including parameterized constructors and constructor overloading:

 In object-oriented programming (OOP), a constructor is a special type of method that is used


to initialize objects of a class. It is called when an object is created, and it is responsible for
setting the initial values of the object's fields.
 Constructors can be either parameterized or non-parameterized. A parameterized
constructor takes one or more parameters, which are used to initialize the object's fields. A
non-parameterized constructor does not take any parameters, and it typically initializes the
object's fields to default values.
 Constructor overloading is a feature that allows a class to have multiple constructors with
different parameter lists. This can be useful for initializing objects in different ways,
depending on the needs of the program.

You might also like