


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



Course Code: CSE- Course Title: Object Oriented Programming
Date of Submission: 1 0.06.
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.