0% found this document useful (0 votes)
2 views49 pages

Java Unit II

The document outlines the syllabus for a Java course, focusing on classes and objects, methods, and access modifiers. It explains the concepts of classes and objects in Object-Oriented Programming, including class declaration, object instantiation, and the differences between classes and objects. Additionally, it covers access modifiers, constructors, and provides examples of Java code to illustrate these concepts.

Uploaded by

temporaryoppoa12
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views49 pages

Java Unit II

The document outlines the syllabus for a Java course, focusing on classes and objects, methods, and access modifiers. It explains the concepts of classes and objects in Object-Oriented Programming, including class declaration, object instantiation, and the differences between classes and objects. Additionally, it covers access modifiers, constructors, and provides examples of Java code to illustrate these concepts.

Uploaded by

temporaryoppoa12
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

PAPPI REDDYM. Tech, (Ph. D); Assoc. Professor Dept.

Of CSE ||II-I- JAVA (R23)

UNIT-II
SYLLABUS: Classes and Objects: Introduction, Class Declaration and
Modifiers, Class Members, Declaration of Class Objects, Assigning One Object
to Another, Access Control for Class Members, Accessing Private Members of
Class, Constructor Methods for Class, Overloaded Constructor Methods,
Nested Classes, Final Class and Methods, Passing Arguments by Value and by
Reference, Keyword this.
Methods: Introduction, Defining Methods, Overloaded Methods, Overloaded
Constructor Methods, Class Objects as Parameters in Methods, Access
Control, Recursive Methods, Nesting of Methods, Overriding Methods,
Attributes Final and Static.
Classes and Objects Introduction:
Classes and objects are basic concepts of Object-Oriented Programming (OOPs)
that are used to represent real-world concepts and entities. The class
represents a group of objects having similar properties and behavior. For
example, the animal type Dog is a class while a particular dog
named Tommy is an object of the Dog class.

Java Classes
A class in Java is a set of objects which shares common characteristics/
behavior and common properties/ attributes. It is a user-defined blueprint or
prototype from which objects are created. For example, Student is a class
while a particular student named Ravi is an object.
Properties of Java Classes
1. Class is not a real-world entity. It is just a template or blueprint or
prototype from which objects are created.
2. Class does not occupy memory.
3. Class is a group of variables of different data types and a group of
methods.
4. A Class in Java can contain:
• Data member
• Method
• Constructor
• Nested Class
• Interface

VISWAM ENGINEERING COLLEGE P a g e 1 | 49


PAPPI REDDYM. Tech, (Ph. D); Assoc. Professor Dept. Of CSE ||II-I- JAVA (R23)

Syntax to declare a class:


1. class <class_name>{
2. field;
3. method;
4. }
EXAMPLE:
// Java Program for class example

class Student {
// data member (also instance variable)
int id;
// data member (also instance variable)
String name;

public static void main(String args[])


{
// creating an object of
// Student
Student s1 = new Student();
[Link]([Link]);
[Link]([Link]);
}
}
OUTPUT:
0
null
Components of Java Classes
In general, class declarations can include these components, in order:
1. Modifiers: A class can be public or has default access (Refer this for
details).
2. Class keyword: class keyword is used to create a class.
3. Class name: The name should begin with an initial letter (capitalized
by convention).
4. Superclass(if any): The name of the class’s parent (superclass), if any,
preceded by the keyword extends. A class can only extend (subclass)
one parent.

VISWAM ENGINEERING COLLEGE P a g e 2 | 49


PAPPI REDDYM. Tech, (Ph. D); Assoc. Professor Dept. Of CSE ||II-I- JAVA (R23)

5. Interfaces(if any): A comma-separated list of interfaces implemented


by the class, if any, preceded by the keyword implements. A class can
implement more than one interface.
6. Body: The class body is surrounded by braces, { }.
Java Objects
An object in Java is a basic unit of Object-Oriented Programming and
represents real-life entities. Objects are the instances of a class that are
created to use the attributes and methods of a class. A typical Java program
creates many objects, which as you know, interact by invoking methods. An
object consists of :
1. State: It is represented by attributes of an object. It also reflects the
properties of an object.
2. Behavior: It is represented by the methods of an object. It also
reflects the response of an object with other objects.
3. Identity: It gives a unique name to an object and enables one object
to interact with other objects.
Example of an object: dog

Java Objects
Objects correspond to things found in the real world. For example, a graphics
program may have objects such as “circle”, “square”, and “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.

VISWAM ENGINEERING COLLEGE P a g e 3 | 49


PAPPI REDDYM. Tech, (Ph. D); Assoc. Professor Dept. Of CSE ||II-I- JAVA (R23)

Example:

Java Object Declaration

As we declare variables like (type name;). This notifies the compiler that we
will use the name to refer to data whose type is type. With a primitive variable,
this declaration also reserves the proper amount of memory for the variable.
So for reference variables , the type must be strictly a concrete class name. In
general, we can’t create objects of an abstract class or an interface.
Dog tuffy;

VISWAM ENGINEERING COLLEGE P a g e 4 | 49


PAPPI REDDYM. Tech, (Ph. D); Assoc. Professor Dept. Of CSE ||II-I- JAVA (R23)

Difference between Java Class and Objects


The differences between class and object in Java are as follows:
Class Object

Class is the blueprint of an object.


An object is an instance of the class.
It is used to create objects.

No memory is allocated when a Memory is allocated as soon as an


class is declared. object is created.

An object is a real-world entity such


A class is a group of similar objects.
as a book, car, etc.

Class is a logical entity. An object is a physical entity.

Objects can be created many times


A class can only be declared once.
as per requirement.

Objects of the class car can be BMW,


An example of class can be a car.
Mercedes, Ferrari, etc.

Access Modifiers in Java:


Access modifiers help to restrict the scope of a class, constructor, variable,
method, or data member. It provides security, accessibility, etc to the user
depending upon the access modifier used with the element.
Types of Access Modifiers in Java
There are four types of access modifiers available in Java:
1. Default – No keyword required
2. Private
3. Protected
4. Public

VISWAM ENGINEERING COLLEGE P a g e 5 | 49


PAPPI REDDYM. Tech, (Ph. D); Assoc. Professor Dept. Of CSE ||II-I- JAVA (R23)

1. Default Access Modifier


When no access modifier is specified for a class, method, or data member – It is
said to be having the default access modifier by default. The data members,
classes, or methods that are not declared using any access modifiers i.e. having
default access modifiers are accessible only within the same package.
Program 1:
// Java program to illustrate default modifier
package p1;
// Class Geek is having Default access modifier
class Geek
{
void display()
{
[Link]("Hello World!");
}
}
Output:
Compile time error

2. Private Access Modifier


The private access modifier is specified using the keyword private. The
methods or data members declared as private are accessible only within the
class in which they are declared.
• Any other class of the same package will not be able to
access these members.
• Top-level classes or interfaces can not be declared as private
because

VISWAM ENGINEERING COLLEGE P a g e 6 | 49


PAPPI REDDYM. Tech, (Ph. D); Assoc. Professor Dept. Of CSE ||II-I- JAVA (R23)

o private means “only visible within the enclosing class”.


o protected means “only visible within the enclosing class and any
subclasses”
• // Java program to illustrate error while
• // Using class from different package with
• // Private Modifier
• package p1;
• // Class A
• class A {
• private void display()
• {
• [Link]("GeeksforGeeks");
• }
• }
• // Class B
• class B {
• public static void main(String args[])
• {
• A obj = new A();
• // Trying to access private method
• // of another class
• [Link]();
• }
• }
Output:
error: display() has private access in A
[Link]();

3. Protected Access Modifier


The protected access modifier is specified using the keyword protected.
The methods or data members declared as protected are accessible within
the same package or subclasses in different packages.

Program 1:
// Java Program to Illustrate
// Protected Modifier
package p1;

// Class A

VISWAM ENGINEERING COLLEGE P a g e 7 | 49


PAPPI REDDYM. Tech, (Ph. D); Assoc. Professor Dept. Of CSE ||II-I- JAVA (R23)

public class A {
protected void display()
{
[Link]("JAVA");
}
}
Output:
JAVA

[Link] Access modifier


The public access modifier is specified using the keyword public.
• The public access modifier has the widest scope among all other
access modifiers.
• Classes, methods, or data members that are declared as public
are accessible from everywhere in the program. There is no
restriction on the scope of public data members.
Program 1:
Java
// Java program to illustrate
// public modifier
package p1;
public class A
{
public void display()
{
[Link]("JAVA");
}
}
Output:
JAVA

VISWAM ENGINEERING COLLEGE P a g e 8 | 49


PAPPI REDDYM. Tech, (Ph. D); Assoc. Professor Dept. Of CSE ||II-I- JAVA (R23)

Accessing private members of class in java:


One way to access inner-class private members from outer classes is by using
getter and setter methods. You can declare public getter and setter
methods in the inner class, which can be accessed from the outer class to get or
set the values of private members.
If we want to access Private Field and method using Reflection, we just need
to call setAccessible(true) on the field or method object which you want to
access. [Link](String fieldName)
or [Link]() can be used to get private fields. Whereas
[Link](String methodName, Class<?>… parameterTypes)
or [Link]() can be used to get private methods.
1. Accessing private Field

// Access Private Field Using Reflection in Java


import [Link]; // Student class declaration
class Student { // private fields
private String name;
private int age; // Constructor
public Student(String name, int age)
{
[Link] = name;
[Link] = age;
} // Getters and setters
public String getName() { return name; }
public void setName(String name) { [Link] = name; }
private int getAge() { return age; }
public void setAge(int age) { [Link] = age; }
// Override toString method to get required
// output at terminal
@Override public String toString()
{
return "Employee [name=" + name + ", age=" + age
+ "]";
}
}
// Program will throw an exception on online IDE

VISWAM ENGINEERING COLLEGE P a g e 9 | 49


PAPPI REDDYM. Tech, (Ph. D); Assoc. Professor Dept. Of CSE ||II-I- JAVA (R23)

// Compile and run the program on offline IDE


class GFG {
public static void main(String[] args)
{
try {
// Student object created
Student e = new Student("Kapil", 23);
// Create Field object
Field privateField
= [Link]("name");
// Set the accessibility as true
[Link](true);
// Store the value of private field in variable
String name = (String)[Link](e);
// Print the value
[Link]("Name of Student:" + name);
}
catch (Exception e) {
[Link]();
}
}
}
Output:
Name of Student:Kapil
2. Accessing private Method

// Access Private Method Using Reflection in Java


import [Link];
import [Link];
// Student class declaration
class Student {
// Private fields
private String name;
private int age;
// Constructor
public Student(String name, int age)
{

VISWAM ENGINEERING COLLEGE P a g e 10 | 49


PAPPI REDDYM. Tech, (Ph. D); Assoc. Professor Dept. Of CSE ||II-I- JAVA (R23)

[Link] = name;
[Link] = age;
}
// Getters and Setters
public String getName() { return name; }
public void setName(String name) { [Link] = name; }
private int getAge() { return age; }
public void setAge(int age) { [Link] = age; }
// Override to string method to get
// Required output when called
@Override public String toString()
{
return "Employee [name=" + name + ", age=" + age
+ "]";
}
}
class GFG {
public static void main(String[] args)
{
try {
// Student class object
Student e = new Student("Kapil", 23);
// Create Method object
Method privateMethod= [Link]("getAge");
// Set the accessibility as true
[Link](true);
// Store the returned value of
// private methods in variable
int age = (int)[Link](e);
[Link]("Age of Student: " + age);
}
catch (Exception e) {
[Link]();
}
}
}
Output:
Age of Student: 23

VISWAM ENGINEERING COLLEGE P a g e 11 | 49


PAPPI REDDYM. Tech, (Ph. D); Assoc. Professor Dept. Of CSE ||II-I- JAVA (R23)

Constructors in Java:
❖ A constructor is a block of codes similar to the method. It is called when
an instance of the class is created. At the time of calling constructor,
memory for the object is allocated in the memory.
❖ It is a special type of method which is used to initialize the object.
❖ Every time an object is created using the new() keyword, at least one
constructor is called.
❖ It calls a default constructor if there is no constructor available in the
class. In such case, Java compiler provides a default constructor by
default.

Rules for creating Java constructor

There are two rules defined for the constructor.

1. Constructor name must be the same as its class name


2. A Constructor must have no explicit return type
3. A Java constructor cannot be abstract, static, final, and synchronized

Types of Constructors in Java


Now is the correct time to discuss the types of the constructor, so primarily
there are three types of constructors in Java are mentioned below:
• Default Constructor
• Parameterized Constructor
• Copy Constructor

1. Default Constructor in Java


A constructor that has no parameters is known as default the constructor. A
default constructor is invisible. And if we write a constructor with no
arguments, the compiler does not create a default constructor. It is taken out.
It is being overloaded and called a parameterized constructor. The default
constructor changed into the parameterized constructor

VISWAM ENGINEERING COLLEGE P a g e 12 | 49


PAPPI REDDYM. Tech, (Ph. D); Assoc. Professor Dept. Of CSE ||II-I- JAVA (R23)

Example:

// Java Program to demonstrate


// Default Constructor
import [Link].*;
// Driver class
class GFG {
// Default Constructor
GFG() { [Link]("Default constructor"); }
// Driver function
public static void main(String[] args)
{
GFG hello = new GFG();
}
}

Output
Default constructor
2. Parameterized Constructor in Java
A constructor that has parameters is known as parameterized constructor. If
we want to initialize fields of the class with our own values, then use a
parameterized constructor.
Example:
// Java Program for Parameterized Constructor
import [Link].*;
class Geek {
// data members of the class.
String name;
int id;
Geek(String name, int id)
{
[Link] = name;
[Link] = id;
}
}
class GFG {
public static void main(String[] args)
{
// This would invoke the parameterized constructor.

VISWAM ENGINEERING COLLEGE P a g e 13 | 49


PAPPI REDDYM. Tech, (Ph. D); Assoc. Professor Dept. Of CSE ||II-I- JAVA (R23)

Geek geek1 = new Geek("Avinash", 68);


[Link]("GeekName :" + [Link]
+ " and GeekId :" + [Link]);
}
}

Output
GeekName :Avinash and GeekId :68

3. Copy Constructor in Java


Unlike other constructors copy constructor is passed with another object
which copies the data available from the passed object to the newly created
object.
Example:
Java
// Java Program for Copy Constructor
import [Link].*;

class Geek {
// data members of the class.
String name;
int id;

// Parameterized Constructor
Geek(String name, int id)
{
[Link] = name;
[Link] = id;
}

// Copy Constructor
Geek(Geek obj2)
{
[Link] = [Link];
[Link] = [Link];
}
}
class GFG {
public static void main(String[] args)

VISWAM ENGINEERING COLLEGE P a g e 14 | 49


PAPPI REDDYM. Tech, (Ph. D); Assoc. Professor Dept. Of CSE ||II-I- JAVA (R23)

{
// This would invoke the parameterized constructor.
[Link]("First Object");
Geek geek1 = new Geek("Avinash", 68);
[Link]("GeekName :" + [Link] + " and GeekId :" +
[Link]);

[Link]();

// This would invoke the copy constructor.


Geek geek2 = new Geek(geek1);
[Link](
"Copy Constructor used Second Object");
[Link]("GeekName :" + [Link] + " and GeekId :" +
[Link]);
}
}
Output
First Object
GeekName :Avinash and GeekId :68

Copy Constructor used Second Object


GeekName :Avinash and GeekId :68

Constructor Overloading in Java:


The constructor overloading can be defined as the concept of having more than
one constructor with different parameters so that every constructor can
perform a different task.

Consider the following Java program, in which we have used different


constructors in the class.

VISWAM ENGINEERING COLLEGE P a g e 15 | 49


PAPPI REDDYM. Tech, (Ph. D); Assoc. Professor Dept. Of CSE ||II-I- JAVA (R23)

Example
1. public class Student {
2. //instance variables of the class
3. int id;
4. String name;
5.
6. Student(){
7. [Link]("this a default constructor");
8. }
9. Student(int i, String n){
10. id = i;
11. name = n;
12. }
13. public static void main(String[] args) {
14. //object creation
15. Student s = new Student();
16. [Link]("\nDefault Constructor values: \n");
17. [Link]("Student Id : "+[Link] + "\nStudent Name : "+[Link]);
18. [Link]("\nParameterized Constructor values: \n");
19. Student student = new Student(10, "David");
20. [Link]("Student Id : "+[Link] + "\nStudent Name : "+stu
[Link]);
21. }
22. }

Output:

this a default constructor


Default Constructor values:

Student Id : 0
Student Name : null

Parameterized Constructor values:


Student Id : 10
Student Name : David

VISWAM ENGINEERING COLLEGE P a g e 16 | 49


PAPPI REDDYM. Tech, (Ph. D); Assoc. Professor Dept. Of CSE ||II-I- JAVA (R23)

In the above example, the Student class constructor is overloaded with two
different constructors, I.e., default and parameterized.

Constructor Overloading Vs. Method Overloading


Aspect Constructor Overloading Method Overloading

Method/ The constructors and the class share Within a class, methods
Constructor the same name. share the same name.
Name

Return Type A return type is absent from A return type is given for
constructors. methods.

Invocation Constructors are triggered when an The names of the


object is formed using the new methods are used to
keyword. explicitly call them.

Purpose used to provide several methods for used to give users several
creating objects and to initialize options for carrying out
object characteristics. the same action on items.

Parameter Different argument lists in Different parameter lists


List constructors are involved in are used in methods
constructor overloading. when method
overloading occurs.

Inheritance Although subclasses cannot inherit Subclasses inherit


constructors, they can be invoked by overloading methods,
using the super keyword. which can be overridden
in child classes.

Default In the event that a class lacks defined The compiler doesn't
Constructor constructors, the compiler offers a offer a default method if a
default constructor that takes no class has no declared
inputs. constructors.

VISWAM ENGINEERING COLLEGE P a g e 17 | 49


PAPPI REDDYM. Tech, (Ph. D); Assoc. Professor Dept. Of CSE ||II-I- JAVA (R23)

Use Cases Constructor overloading is mostly Multiple ways to execute


utilized for initializing objects and an action on objects of a
offering many approaches to class are provided via
building class objects. method overloading.

Nested classes in java:


Java inner class or nested class is a class that is declared inside the class or
interface.
We use inner classes to logically group classes and interfaces in one place to be
more readable and maintainable.
Additionally, it can access all the members of the outer class, including private
data members and methods.
Syntax of Inner class
1. class Java_Outer_class{
2. //code
3. class Java_Inner_class{
4. //code
5. }
6. }
Advantage of Java inner classes
There are three advantages of inner classes in Java. They are as follows:
1. Nested classes represent a particular type of relationship that is it can
access all the members (data members and methods) of the outer
class, including private.
2. Nested classes are used to develop more readable and maintainable
code because it logically group classes and interfaces in one place only.
3. Code Optimization: It requires less code to write.
Need of Java Inner class
Sometimes users need to program a class in such a way so that no other class
can access it. Therefore, it would be better if you include it within other classes.
If all the class objects are a part of the outer object then it is easier to nest that
class inside the outer class. That way all the outer class can access all the objects
of the inner class.
Difference between nested class and inner class in Java
An inner class is a part of a nested class. Non-static nested classes are known as
inner classes.

VISWAM ENGINEERING COLLEGE P a g e 18 | 49


PAPPI REDDYM. Tech, (Ph. D); Assoc. Professor Dept. Of CSE ||II-I- JAVA (R23)

Types of Nested classes


There are two types of nested classes non-static and static nested classes. The
non-static nested classes are also known as inner classes.
o Non-static nested class (inner class)
1. Member inner class
2. Anonymous inner class
3. Local inner class
o Static nested class

Type Description

Member Inner A class created within class and outside method.


Class

Anonymous Inner A class created for implementing an interface or extending


Class class. The java compiler decides its name.

Local Inner Class A class was created within the method.

Static Nested A static class was created within the class.


Class

Nested Interface An interface created within class or interface.

Comparison between a normal or regular class and a static nested class


[Link]. Normal/Regular inner class Static nested class

Without an outer class object


Without an outer class object
existing, there may be a static
existing, there cannot be an inner
nested class object. That is, a
1. class object. That is, the inner class
static nested class object is
object is always associated with the
not associated with the outer
outer class object.
class object.

VISWAM ENGINEERING COLLEGE P a g e 19 | 49


PAPPI REDDYM. Tech, (Ph. D); Assoc. Professor Dept. Of CSE ||II-I- JAVA (R23)

[Link]. Normal/Regular inner class Static nested class

As the main() method can’t be As the main() method can be


declared, the regular inner class declared, the static nested
2.
can’t be invoked directly from the class can be invoked directly
command prompt. from the command prompt.

Both static and non-static members Only a static member of an


3. of the outer class can be accessed outer class can be accessed
directly. directly.

CALL BY VALUE AND CALL BY REFERENCE:


(OR)
Passing arguments by value and by reference in java:
Pass by Value: In the pass by value concept, the method is called by passing a
value. So, it is called pass by value. It does not affect the original parameter.

Pass by Reference: In the pass by reference concept, the method is called using
an alias or reference of the actual parameter. So, it is called pass by reference.
It forwards the unique identifier of the object to the method. If we made
changes to the parameter's instance member, it would affect the original value.

Java does not support pass by reference concept.

Example:
[Link]

1. public class Bike {


2. private double speed;
3. public void Model(){}
4. public Bike(double s){
5. [Link]=s;
6. }
7. public double getSpeed() {
8. return speed;

VISWAM ENGINEERING COLLEGE P a g e 20 | 49


PAPPI REDDYM. Tech, (Ph. D); Assoc. Professor Dept. Of CSE ||II-I- JAVA (R23)

9. }
10. public void setSpeed(double s1) {
11. [Link] = speed;
12. }
13. }

Now, create a TestSpeed class to swap variables:

[Link]

1. public class TestSpeed {


2. public static void main(String[] args) {
3. Bike apache = new Bike(180); //memory references
4. Bike pulsar = new Bike(200);
5.
6. swap(apache, pulsar);
7. [Link]("Apache's Speed is ="+[Link]());
8. [Link]("Pulsar's Speed is ="+[Link]());
9. Demo(pulsar);
10. [Link]("Pulsar's Speed is ="+[Link]());
11. }
12.
13. private static void Demo(Bike b) {
14. [Link](180);
15. b = new Bike(280);
16. [Link](200);
17. }
18. public static void swap(Object o1, Object o2)// method for swapping
variables
19. {
20. Object temp = o1;
21. o1=o2;
22. o2=temp;
23. }
24. }

VISWAM ENGINEERING COLLEGE P a g e 21 | 49


PAPPI REDDYM. Tech, (Ph. D); Assoc. Professor Dept. Of CSE ||II-I- JAVA (R23)

Output:

Apache's Speed is =180.0


Pulsar's Speed is =200.0
Pulsar's Speed is =200.0

Java Pass by Value Example


Passing the parameters by values does not affect the original variable. Below is
the example of Passing by Value:

[Link]

1. public class PBVDemo {


2. int a=100;
3. void change(int a){
4. a=a+100;//Changing values It will be locally)
5. }
6. public static void main(String args[]){
7. PBVDemo p=new PBVDemo(); //Creating object
8. [Link](" Value (before change)="+p.a);
9. [Link](500); //Passing value
10. [Link](" Value (after change)="+p.a);
11. }
12. }

Output:

Value (before change)= 100


Value (after change)= 100

VISWAM ENGINEERING COLLEGE P a g e 22 | 49


PAPPI REDDYM. Tech, (Ph. D); Assoc. Professor Dept. Of CSE ||II-I- JAVA (R23)

Keyword this:
There can be a lot of usage of Java this keyword. In Java, this is a reference
variable that refers to the current object.

Usage of Java this keyword


Here is given the 6 usage of java this keyword.

1. this can be used to refer current class instance variable.


2. this can be used to invoke current class method (implicitly)
3. this() can be used to invoke current class constructor.
4. this can be passed as an argument in the method call.
5. this can be passed as argument in the constructor call.
6. this can be used to return the current class instance from the method.

1) this: to refer current class instance variable

The this keyword can be used to refer current class instance variable. If there
is ambiguity between the instance variables and parameters, this keyword
resolves the problem of ambiguity.

2) this: to invoke current class method

You may invoke the method of the current class by using the this keyword. If
you don't use the this keyword, compiler automatically adds this keyword
while invoking the method. Let's see the example

VISWAM ENGINEERING COLLEGE P a g e 23 | 49


PAPPI REDDYM. Tech, (Ph. D); Assoc. Professor Dept. Of CSE ||II-I- JAVA (R23)

3) this() : to invoke current class constructor

The this() constructor call can be used to invoke the current class constructor.
It is used to reuse the constructor. In other words, it is used for constructor
chaining.

4) this: to pass as an argument in the method

The this keyword can also be passed as an argument in the method. It is mainly
used in the event handling.

5) this: to pass as argument in the constructor call

We can pass the this keyword in the constructor also. It is useful if we have to
use one object in multiple classes

6) this keyword can be used to return current class instance

We can return this keyword as an statement from the method. In such case,
return type of the method must be the class type (non-primitive).

VISWAM ENGINEERING COLLEGE P a g e 24 | 49


PAPPI REDDYM. Tech, (Ph. D); Assoc. Professor Dept. Of CSE ||II-I- JAVA (R23)

PART-B
Methods
Introduction:
In general, a method is a way to perform some task. Similarly, the method in
Java is a collection of instructions that performs a specific task. It provides the
reusability of code. We can also easily modify code using methods. In this
section, we will learn what is a method in Java, types of methods, method
declaration, and how to call a method in Java.

Defining Methods:
A method is a block of code or collection of statements or a set of code
grouped together to perform a certain task or operation. It is used to achieve
the reusability of code. We write a method once and use it many times. We do
not require to write code again and again. It also provides the easy
modification and readability of code, just by adding or removing a chunk of
code. The method is executed only when we call or invoke it.

The most important method in Java is the main() method. If you want to
read more about the main() method.
Method Declaration:
The method declaration provides information about method attributes,
such as visibility, return-type, name, and arguments. It has six components that
are known as method header, as we have shown in the following figure.

VISWAM ENGINEERING COLLEGE P a g e 25 | 49


PAPPI REDDYM. Tech, (Ph. D); Assoc. Professor Dept. Of CSE ||II-I- JAVA (R23)

Method Signature: Every method has a method signature. It is a part of the


method declaration. It includes the method name and parameter list.

Access Specifier: Access specifier or modifier is the access type of the method.
It specifies the visibility of the method. Java provides four types of access
specifier:

o Public: The method is accessible by all classes when we use public


specifier in our application.
o Private: When we use a private access specifier, the method is accessible
only in the classes in which it is defined.
o Protected: When we use protected access specifier, the method is
accessible within the same package or subclasses in a different package.
o Default: When we do not use any access specifier in the method
declaration, Java uses default access specifier by default. It is visible only
from the same package only.

Return Type: Return type is a data type that the method returns. It may have
a primitive data type, object, collection, void, etc. If the method does not return
anything, we use void keyword.

Method Name: It is a unique name that is used to define the name of a method.
It must be corresponding to the functionality of the method. Suppose, if we are
creating a method for subtraction of two numbers, the method name must
be subtraction(). A method is invoked by its name.

Parameter List: It is the list of parameters separated by a comma and enclosed


in the pair of parentheses. It contains the data type and variable name. If the
method has no parameter, left the parentheses blank.

Method Body: It is a part of the method declaration. It contains all the actions
to be performed. It is enclosed within the pair of curly braces.

VISWAM ENGINEERING COLLEGE P a g e 26 | 49


PAPPI REDDYM. Tech, (Ph. D); Assoc. Professor Dept. Of CSE ||II-I- JAVA (R23)

Types of Methods in Java


There are two types of methods in Java:

1. Predefined Method
In Java, predefined methods are the method that is already defined in the Java
class libraries is known as predefined methods. It is also known as the
standard library method or built-in method. We can directly use these
methods just by calling them in the program at any point.

2. User-defined Method
The method written by the user or programmer is known as a user-defined
method. These methods are modified according to the requirement.
Ways to Create Method in Java

There are two ways to create a method in Java:


1. Instance Method: Access the instance data using the object name. Declared
inside a class.
Syntax:
// Instance Method
void method_name(){
body // instance area
}
2. Static Method: Access the static data using class name. Declared inside
class with static keyword.
Syntax:
//Static Method
static void method_name(){
body // static area
}

Method Signature:
It consists of the method name and a parameter list (number of parameters,
type of the parameters, and order of the parameters). The return type and
exceptions are not considered as part of it.
Method Signature of the above function:
max(int x, int y) Number of parameters is 2, Type of parameter is int.

VISWAM ENGINEERING COLLEGE P a g e 27 | 49


PAPPI REDDYM. Tech, (Ph. D); Assoc. Professor Dept. Of CSE ||II-I- JAVA (R23)

Naming a Method
A method name is typically a single word that should be a verb in lowercase
or a multi-word, that begins with a verb in lowercase followed by
an adjective, noun. After the first word, the first letter of each word should
be capitalized.
Rules to Name a Method:
• While defining a method, remember that the method name must be
a verb and start with a lowercase letter.
• If the method name has more than two words, the first name must be
a verb followed by an adjective or noun.
• In the multi-word method name, the first letter of each word must be
in uppercase except the first word. For example, findSum,
computeMax, setX, and getX.
Generally, a method has a unique name within the class in which it is defined
but sometimes a method might have the same name as other method names
within the same class as method overloading is allowed in Java.

Method Calling
The method needs to be called for use its functionality. There can be three
situations when a method is called:
A method returns to the code that invoked it when:
• It completes all the statements in the method.
• It reaches a return statement.
• Throws an exception.
• / Java Program to Illustrate Methods

• // Importing required classes
• import [Link].*;

• // Class 1
• // Helper class
• class Addition {

• // Initially taking sum as 0
• // as we have not started computation
• int sum = 0;

• // Method
• // To add two numbers

VISWAM ENGINEERING COLLEGE P a g e 28 | 49


PAPPI REDDYM. Tech, (Ph. D); Assoc. Professor Dept. Of CSE ||II-I- JAVA (R23)

• public int addTwoInt(int a, int b)


• {

• // Adding two integer value
• sum = a + b;

• // Returning summation of two values
• return sum;
• }
• }

• // Class 2
• // Helper class
• class GFG {

• // Main driver method
• public static void main(String[] args)
• {

• // Creating object of class 1 inside main() method
• Addition add = new Addition();

• // Calling method of above class
• // to add two integer
• // using instance created
• int s = [Link](1, 2);

• // Printing the sum of two numbers
• [Link]("Sum of two integer values :"
• + s);
• }
• }

Output
Sum of two integer values :3

VISWAM ENGINEERING COLLEGE P a g e 29 | 49


PAPPI REDDYM. Tech, (Ph. D); Assoc. Professor Dept. Of CSE ||II-I- JAVA (R23)

There are several advantages to using methods in Java, including:


• Reusability: Methods allow you to write code once and use it many
times, making your code more modular and easier to maintain.
• Abstraction: Methods allow you to abstract away complex logic and
provide a simple interface for others to use. This makes your code more
readable and easier to understand.
• Improved readability: By breaking up your code into smaller, well-
named methods, you can make your code more readable and easier to
understand.
• Encapsulation: Methods allow you to encapsulate complex logic and
data, making it easier to manage and maintain.
• Separation of concerns: By using methods, you can separate different
parts of your code and assign different responsibilities to different
methods, improving the structure and organization of your code.
• Improved modularity: Methods allow you to break up your code into
smaller, more manageable units, improving the modularity of your code.
• Improved testability: By breaking up your code into smaller, more
manageable units, you can make it easier to test and debug your code.
• Improved performance: By organizing your code into well-structured
methods, you can improve performance by reducing the amount of code
that needs to be executed and by making it easier to cache and optimize
your code.
Method Overloading in Java:
If a class has multiple methods having same name but different in parameters,
it is known as Method Overloading.

Advantage of method overloading

Method overloading increases the readability of the program.

Different ways to overload the method

There are two ways to overload the method in java

1. By changing number of arguments


2. By changing the data type

VISWAM ENGINEERING COLLEGE P a g e 30 | 49


PAPPI REDDYM. Tech, (Ph. D); Assoc. Professor Dept. Of CSE ||II-I- JAVA (R23)

1) Method Overloading: changing no. of arguments

In this example, we have created two methods, first add() method performs
addition of two numbers and second add method performs addition of three
numbers.

In this example, we are creating static methods so that we don't need to create
instance for calling methods.

1. class Adder{
2. static int add(int a,int b){return a+b;}
3. static int add(int a,int b,int c){return a+b+c;}
4. }
5. class TestOverloading1{
6. public static void main(String[] args){
7. [Link]([Link](11,11));
8. [Link]([Link](11,11,11));
9. }}

Output:

22
33
2) Method Overloading: changing data type of arguments

In this example, we have created two methods that differs in data type. The first
add method receives two integer arguments and second add method receives
two double arguments.

1. class Adder{
2. static int add(int a, int b){return a+b;}
3. static double add(double a, double b){return a+b;}
4. }
5. class TestOverloading2{
6. public static void main(String[] args){
7. [Link]([Link](11,11));
8. [Link]([Link](12.3,12.6));
9. }}

VISWAM ENGINEERING COLLEGE P a g e 31 | 49


PAPPI REDDYM. Tech, (Ph. D); Assoc. Professor Dept. Of CSE ||II-I- JAVA (R23)

Output:

22
24.9

Constructor overloading in Java:


we can overload constructors like methods. The constructor overloading can
be defined as the concept of having more than one constructor with different
parameters so that every constructor can perform a different task.

Consider the following Java program, in which we have used different


constructors in the class.

Example
1. public class Student {
2. //instance variables of the class
3. int id;
4. String name;
5.
6. Student(){
7. [Link]("this a default constructor");
8. }
9. Student(int i, String n){
10. id = i;
11. name = n;
12. }
13. public static void main(String[] args) {
14. //object creation
15. Student s = new Student();
16. [Link]("\nDefault Constructor values: \n");
17. [Link]("Student Id : "+[Link] + "\nStudent Name : "+[Link]);
18. [Link]("\nParameterized Constructor values: \n");
19. Student student = new Student(10, "David");
20. [Link]("Student Id : "+[Link] + "\nStudent Name : "+stu
[Link]);

VISWAM ENGINEERING COLLEGE P a g e 32 | 49


PAPPI REDDYM. Tech, (Ph. D); Assoc. Professor Dept. Of CSE ||II-I- JAVA (R23)

21. }
22. }

Output:

this a default constructor

Default Constructor values:

Student Id : 0
Student Name : null

Parameterized Constructor values:

Student Id : 10
Student Name : David

class objects as parameters in methods in java:


Java is strictly passed by value, the precise effect differs between whether
a primitive type or a reference type is passed. When we pass a primitive type
to a method, it is passed by value. But when we pass an object to a method, the
situation changes dramatically, because objects are passed by what is
effectively call-by-reference. Java does this interesting thing that’s sort of a
hybrid between pass-by-value and pass-by-reference.

EXAMPLE:Let us suppose three objects ‘ob1’ , ‘ob2’ and ‘ob3’ are created:

ObjectPassDemo ob1 = new ObjectPassDemo(100, 22);


ObjectPassDemo ob2 = new ObjectPassDemo(100, 22);
ObjectPassDemo ob3 = new ObjectPassDemo(-1, -1);

VISWAM ENGINEERING COLLEGE P a g e 33 | 49


PAPPI REDDYM. Tech, (Ph. D); Assoc. Professor Dept. Of CSE ||II-I- JAVA (R23)

From the method side, a reference of type Foo with a name a is declared and
it’s initially assigned to null.
boolean equalTo(ObjectPassDemo o);

As we call the method equalTo, the reference ‘o’ will be assigned to the object
which is passed as an argument, i.e. ‘o’ will refer to ‘ob2’ as the following
statement execute.
[Link]("ob1 == ob2: " + [Link](ob2));

VISWAM ENGINEERING COLLEGE P a g e 34 | 49


PAPPI REDDYM. Tech, (Ph. D); Assoc. Professor Dept. Of CSE ||II-I- JAVA (R23)

Now as we can see, equalTo method is called on ‘ob1’ , and ‘o’ is referring to
‘ob2’. Since values of ‘a’ and ‘b’ are same for both the references, so
if(condition) is true, so boolean true will be return.
if(o.a == a && o.b == b)
Again ‘o’ will reassign to ‘ob3’ as the following statement execute.
[Link]("ob1 == ob3: " + [Link](ob3));

• Now as we can see, the equalTo method is called on ‘ob1’ , and ‘o’ is
referring to ‘ob3’. Since values of ‘a’ and ‘b’ are not the same for
both the references, so if(condition) is false, so else block will
execute, and false will be returned.

VISWAM ENGINEERING COLLEGE P a g e 35 | 49


PAPPI REDDYM. Tech, (Ph. D); Assoc. Professor Dept. Of CSE ||II-I- JAVA (R23)

Recursive Methods in java:


Recursion is a process in which a function calls itself directly or indirectly is
called recursion and the corresponding function is called a recursive function.
Using a recursive algorithm, certain problems can be solved quite easily.

A few Java recursion examples are

Towers of Hanoi (TOH),

Inorder/Preorder/Postorder Tree Traversals,

DFS of Graph, etc.

Syntax:

1. returntype methodname(){
2. //code to be executed
3. methodname();//calling same method
4. }

Example 1: Finite times

1. public class RecursionExample2 {


2. static int count=0;
3. static void p(){
4. count++;
5. if(count<=5){
6. [Link]("hello "+count);
7. p();
8. }
9. }
10. public static void main(String[] args) {
11. p();
12. }
13. }

VISWAM ENGINEERING COLLEGE P a g e 36 | 49


PAPPI REDDYM. Tech, (Ph. D); Assoc. Professor Dept. Of CSE ||II-I- JAVA (R23)

Output:

hello 1
hello 2
hello 3
hello 4
hello 5

Example 2: Factorial Number

1. public class RecursionExample3 {


2. static int factorial(int n){
3. if (n == 1)
4. return 1;
5. else
6. return(n * factorial(n-1));
7. }
8.
9. public static void main(String[] args) {
10. [Link]("Factorial of 5 is: "+factorial(5));
11. }
12. }
Output:
Factorial of 5 is: 120

Nesting of methods in java:


The methods and variables which we create in a class can only be called by
using the object of that class or, in case of static methods, we can directly call
it by using the name of the class. The methods and variables can be called with
the help of the dot operator. But there is a special case that a method can also
be called by another method with the help of class name, but the condition is
they should be present in the same class.

VISWAM ENGINEERING COLLEGE P a g e 37 | 49


PAPPI REDDYM. Tech, (Ph. D); Assoc. Professor Dept. Of CSE ||II-I- JAVA (R23)

Syntax:
class Main
{
method1(){

// statements
}

method2()
{
// statements

// calling method1() from method2()


method1();
}
method3()
{
// statements

// calling of method2() from method3()


method2();
}
}

VISWAM ENGINEERING COLLEGE P a g e 38 | 49


PAPPI REDDYM. Tech, (Ph. D); Assoc. Professor Dept. Of CSE ||II-I- JAVA (R23)

Method Overriding:
If subclass (child class) has the same method as declared in the parent class, it
is known as method overriding in Java.

In other words, If a subclass provides the specific implementation of the


method that has been declared by one of its parent class, it is known as method
overriding.

Usage of Java Method Overriding


o Method overriding is used to provide the specific implementation of a
method which is already provided by its superclass.
o Method overriding is used for runtime polymorphism

Rules for Java Method Overriding


1. The method must have the same name as in the parent class
2. The method must have the same parameter as in the parent class.
3. There must be an IS-A relationship (inheritance).
4. //Java Program to demonstrate why we need method overriding
5. //Here, we are calling the method of parent class with child
6. //class object.
7. //Creating a parent class
8. class Vehicle{
9. void run(){[Link]("Vehicle is running");}
10. }
11. //Creating a child class
12. class Bike extends Vehicle{
13. public static void main(String args[]){
14. //creating an instance of child class
15. Bike obj = new Bike();
16. //calling the method with child class instance
17. [Link]();
18. }
19. }

VISWAM ENGINEERING COLLEGE P a g e 39 | 49


PAPPI REDDYM. Tech, (Ph. D); Assoc. Professor Dept. Of CSE ||II-I- JAVA (R23)

Output:
Vehicle is running

Example of method overriding

In this example, we have defined the run method in the subclass as defined in
the parent class but it has some specific implementation. The name and
parameter of the method are the same, and there is IS-A relationship between
the classes, so there is method overriding.

1. //Java Program to illustrate the use of Java Method Overriding


2. //Creating a parent class.
3. class Vehicle{
4. //defining a method
5. void run(){[Link]("Vehicle is running");}
6. }
7. //Creating a child class
8. class Bike2 extends Vehicle{
9. //defining the same method as in the parent class
10. void run(){[Link]("Bike is running safely");}
11.
12. public static void main(String args[]){
13. Bike2 obj = new Bike2();//creating object
14. [Link]();//calling method
15. }
16. }

Output:

Bike is running safely

VISWAM ENGINEERING COLLEGE P a g e 40 | 49


PAPPI REDDYM. Tech, (Ph. D); Assoc. Professor Dept. Of CSE ||II-I- JAVA (R23)

A Real Example of Java Method Overriding


Consider a scenario where Bank is a class that provides functionality to get the
rate of interest. However, the rate of interest varies according to banks. For
example, SBI, ICICI and AXIS banks could provide 8%, 7%, and 9% rate of
interest.

Attributes final and static in java:


Static variable: When the value of a variable is not varied, then it is a not good
choice to go for instance variable. At that time we can add static modifier to
that variable. Whenever we declare variable as static, then at the class level a
single variable is created which is shared with the objects. Any change in that
static variable reflect to the other objects operations. If we won’t initialize a
static variable, then by default JVM will provide a default value for static
variable.

But when we declare a static variable with final modifier then we should take
care of the following conventions:
• Declaring variables only as static can lead to change in their values
by one or more instances of a class in which it is declared.
• Declaring them as static final will help you to create a CONSTANT.
Only one copy of variable exists which can’t be reinitialize.

VISWAM ENGINEERING COLLEGE P a g e 41 | 49


PAPPI REDDYM. Tech, (Ph. D); Assoc. Professor Dept. Of CSE ||II-I- JAVA (R23)

Important points about final static variable:

1. Initialization of variable Mandatory: If the static variable declared as


final, then we have to perform initialization explicitly whether we are using
it or not and JVM won’t provide any default value for the final static variable.
// Java program to illustrate the behavior of
// final static variable
class Test {
final static int x;
public static void main(String[] args)
{
}
}
Output:
error: variable x not initialized in the default constructor
2. Initialization before class loading: For final static variable, it is
compulsory that we should perform initialization before class loading
completion. We can initialize a final static variable at the time of
declaration.
// Java program to illustrate that final
// static variable can be initialized
// at the time of declaration
class Test {
final static int x = 10;
public static void main(String[] args)
{
[Link](x);
}
}
Output:
10

VISWAM ENGINEERING COLLEGE P a g e 42 | 49


PAPPI REDDYM. Tech, (Ph. D); Assoc. Professor Dept. Of CSE ||II-I- JAVA (R23)

[Link] inside a static block: We can also initialize a final static


variable inside a static block because we should initialize a final static
variable before class and we know that static block is executed before
main() method.
// Java program to illustrate that final
// static variable can be initialized
// inside static block
class Test {
final static int x;
static
{
x = 10;
}
public static void main(String[] args)
{
[Link](x);
}
}
Output:
10

VISWAM ENGINEERING COLLEGE P a g e 43 | 49


PAPPI REDDYM. Tech, (Ph. D); Assoc. Professor Dept. Of CSE ||II-I- JAVA (R23)

Difference between Static and Final Variable in Java


[Link]. Static Variable Final Variable

1 The static keyword is connected to The final keyword is connected


occupied static classes, variables, to class, variables and
methods and blocks. methods.

2 Here, it is not mandatory to initialise Here, it is mandatory to


the static variable while declaring it.. initialise the final variable
while declaring it.

3 They can be reinitialized. We can not reinitialize the final


keyword.

4 They can only access the static They cannot be inherited.


members of the class, and only static
methods can call them.

5 The object of the static class cannot be It is not possible to inherit the
created, and holds only static members. final class from any class.

6 Static block is used to initialise the Final keyword does not


static variables. support such a block.

VISWAM ENGINEERING COLLEGE P a g e 44 | 49


PAPPI REDDYM. Tech, (Ph. D); Assoc. Professor Dept. Of CSE ||II-I- JAVA (R23)

MCQ’S
1. What is an object in Java?
A. static reference
B. template or blueprint
C. instance of class
D. None of above
2. How many characteristics Object has?
A. 2
B. 3
C. 5
D. 1
3. Which are the object characteristics?
A. State
B. Behavior
C. Identity
D. All of above
4. State characteristic of an object represents
A. the data of an object
B. the behaviors or actions of an object
C. the internal unique identity of an object
D. All of above
5. Behavior characteristic of an object represents
A. the data of an object
B. the behaviors or actions of an object
C. the internal unique identity of an object
D. All of above
6. Identity characteristic of an object represents
A. the data of an object
B. the behaviors or actions of an object
C. the internal unique identity of an object
D. All of above

VISWAM ENGINEERING COLLEGE P a g e 45 | 49


PAPPI REDDYM. Tech, (Ph. D); Assoc. Professor Dept. Of CSE ||II-I- JAVA (R23)

7. Which is the best definition of an object?


A. An object is a real-world entity
B. An object is a runtime entity
C. The object is an instance of a class
D. All of above
8. What is a class in Java?
A. static reference
B. template or blueprint
C. instance of class
D. None of above
9. A Java class can have
A. Fields and Methods
B. Constructors and Blocks
C. Nested class and interface
D. All of above
10. A variable which doesn't get memory at compile time is
called?
A. static variable
B. local variable
C. instance variable
11. new keyword is used for?
A. allocating memory at runtime
B. allocating memory at compile time
C. releasing memory at runtime
D. All of above
12. An object can be initialize in Java by?
A. reference variable
B. method
C. constructor
D. All of above
13. What are the different ways to create an object in Java?
A. by new keyword
B. by newInstance() or clone() method

VISWAM ENGINEERING COLLEGE P a g e 46 | 49


PAPPI REDDYM. Tech, (Ph. D); Assoc. Professor Dept. Of CSE ||II-I- JAVA (R23)

C. by deserialization & factory method


D. All of Above
14. What is an anonymous object in Java?
A. An object with final properties
B. An object with no reference
C. An object with static methods
D. All of above
15. Which of these class is superclass of every class in Java?
a) String class
b) Object class
c) Abstract class
d) ArrayList class
16. Which of these method of Object class can clone an object?
a) Objectcopy()
b) copy()
c) Object clone()
d) clone()
17. Which of these method of Object class is used to obtain class of an
object at run time?
a) get()
b) void getclass()
c) Class getclass()
d) None of the mentioned
18. Which of these keywords can be used to prevent inheritance of a
class?
a) super
b) constant
c) class
d) final
19. Which of these keywords cannot be used for a class which has
been declared final?
a) abstract
b) extends
c) abstract and extends
d) none of the mentioned
20. Which of these class relies upon its subclasses for complete
implementation of its methods?
a) Object class

VISWAM ENGINEERING COLLEGE P a g e 47 | 49


PAPPI REDDYM. Tech, (Ph. D); Assoc. Professor Dept. Of CSE ||II-I- JAVA (R23)

b) abstract class
c) ArrayList class
d) None of the mentioned

21. What will be the output of the following Java code?

22. class Output


23. {
24. public static void main(String args[])
25. {
26. Object obj = new Object();
27. [Link]([Link]());
28. }
29. }
a) Object
b) class Object
c) class [Link]
d) Compilation Error

VISWAM ENGINEERING COLLEGE P a g e 48 | 49


PAPPI REDDYM. Tech, (Ph. D); Assoc. Professor Dept. Of CSE ||II-I- JAVA (R23)

IMPORTANT QUESTIONS
2-Marks:
1. Define method overloading.
2. What is the use of final keyword?
3. Difference between abstract class and object class.
4. Compare class & Object.
5. Define class. Give an example.
6. Define subclass. Illustrate with example.
7. Differentiate abstract classes and interface.
8. Define recursion. Illustrate.
9. What is meaning by method overriding? Why is it required?
10. Why is method assigned as public and static?

5/10-Marks:
[Link] is abstract class? Explain all the cases to implement abstract
class.
2. Write a java program to find the factorial value of the given number
using recursion.
[Link] is the method? Explain method overloading with the relevant
java program.
[Link] constructing overloading and method overloading with an
example.
[Link] the different ways of passing parameters to a function.
6.A) what are the constructors in java programming language? Explain.
B) define method overloading. Develop a block of code to overload a
function to add and multiple any two complex numbers.
[Link] the different methods supported in object class with example.
[Link] method overloading and constructor overloading with
example programs.
[Link] the help of a sample java program explain methods overloading.

VISWAM ENGINEERING COLLEGE P a g e 49 | 49

You might also like