Polymorphism in Java: Method Overloading and Overriding with Examples, Schemes and Mind Maps of Object Oriented Programming

This assignment provides a clear and concise explanation of polymorphism in java, focusing on two key mechanisms: compile-time polymorphism (method overloading) and runtime polymorphism (method overriding). It illustrates these concepts with practical examples, demonstrating how to overload methods within a class and override methods inherited from a parent class. The assignment also includes a section on comparing strings in java, highlighting the differences between using the equals() method and the == operator.

Typology: Schemes and Mind Maps

2022/2023

Available from 02/01/2025

imran-nazir-1
imran-nazir-1 🇧🇩

6 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Assignment
Course Code:CSE-121
Course Title:ObjectOriented
Programming
SUBMITTED TO
SUBMITTED BY
Date of Submission:10.06.2024
Muntasir Karim Chowdhury
Lecturer
Department of Computer Science and Engineering
Feni University
Name:HasanImranNazir
StudentID:232031040
Batch:31th(UG)
DepartmentofCSE
Feni University
pf3
pf4

Partial preview of the text

Download Polymorphism in Java: Method Overloading and Overriding with Examples and more Schemes and Mind Maps Object Oriented Programming in PDF only on Docsity!

Assignment

Course Code: CSE- Course Title: Object Oriented Programming

SUBMITTED TO

SUBMITTED BY

Date of Submission: 1 0.06.

Muntasir Karim Chowdhury

Lecturer

Department of Computer Science and Engineering

Feni University

Name: Hasan Imran Nazir

Student ID: 232031040

Batch: 31th (UG)

Department of CSE

Feni University

Polymorphism in Java

In Java, polymorphism manifests through two primary mechanisms:

Compile-Time Polymorphism (Method Overloading)

This technique leverages the concept of method overloading within a class.

Example:

In this example, the calculateArea method is overloaded. The compiler selects the appropriate method (calculateArea with no arguments, calculateArea with a single double argument, or calculateArea with two double arguments) based on the arguments used in the call.

Compare two strings in Java

Using the equals() method

This is the recommended approach for comparing strings based on their content.

Using the == operator

This operator compares the object references themselves, not the string content.