UrbanPro

Learn Java Training from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

Why Operator Overloading in not allowed in JAVA?

Asked by Last Modified  

14 Answers

Learn Java

Follow 0
Answer

Please enter your answer

Tutor - Maths and computer science

Java does not support operator overloading by programmers. This is not the same as stating that Java does not need operator overloading. Operator overloading is syntactic sugar to express an operation using (arithmetic) symbols. For obvious reasons, the designers of the Java programming language chose...
read more
Java does not support operator overloading by programmers. This is not the same as stating that Java does not need operator overloading. Operator overloading is syntactic sugar to express an operation using (arithmetic) symbols. For obvious reasons, the designers of the Java programming language chose to omit support for operator overloading in the language. This declaration can be found in the Java Language Environment whitepaper: There are no means provided by which programmers can overload the standard arithmetic operators. Once again, the effects of operator overloading can be just as easily achieved by declaring a class, appropriate instance variables, and appropriate methods to manipulate those variables. Eliminating operator overloading leads to great simplification of code. In my personal opinion, that is a wise decision. Consider the following piece of code: String b = "b"; String c = "c"; String a = b + c; Now, it is fairly evident that b and c are concatenated to yield a. But when one consider the following snippet written using a hypothetical language that supports operator overloading, it is fairly evident that using operator overloading does not make for readable code. Person b = new Person("B"); Person c = new Person("C"); Person a = b + c; In order to understand the result of the above operation, one must view the implementation of the overloaded addition operator for the Person class. Surely, that makes for a tedious debugging session, and the code is better implemented as: Person b = new Person("B"); Person c = new Person("C"); Person a = b.copyAttributesFrom(c); read less
Comments

java trainer

Java doesn't support multiple inheritance, no pointers in Java, and no pass by reference in Java. Rarely this question asked in Java interviews, to check how programmer thinks about certain features, which is not supported in Java. Another similar questions is regarding Java being pass by reference,...
read more
Java doesn't support multiple inheritance, no pointers in Java, and no pass by reference in Java. Rarely this question asked in Java interviews, to check how programmer thinks about certain features, which is not supported in Java. Another similar questions is regarding Java being pass by reference, which is mostly appear as, whether Java is pass by value or reference. Though I don't know the real reason behind it, I think following observation make sense on, why Operator overloading is not supported in Java. read less
Comments

1) Simplicity and Cleanliness 2) Avoid Programming Errors 3) JVM Complexity 4) Easy Development of Tools -
Comments

Avoid Programming Errors, Simplicity and Cleanliness, Easy Development of Tools
Comments

Professional Java J2EE Training with certification focus or Maths/English Tuition

Operator Overloading leads to confusion in manipulation of OOPS concept Polymorphism in Programming. Hence it is not used in Java.
Comments

Tutor

java does not support method overloading .But you can see a "+" operator is overloaded in java. it is used for string concatenation as well as addition. but it is a built inside java. a user or a programmer was not able to overload that operator anymore. In that sense java does not support operator overloading....
read more
java does not support method overloading .But you can see a "+" operator is overloaded in java. it is used for string concatenation as well as addition. but it is a built inside java. a user or a programmer was not able to overload that operator anymore. In that sense java does not support operator overloading. But a programmer can overload method.so method overloading is supported in java. There were two major reasons why operator overloading wasn't allowed in Java: "cleanliness" and compiler complexity.. Given the human tendency to assign specific meanings to single symbols, it is hard to get programmers to wrap their heads around multiple meanings for operators. read less
Comments

Sr. Communication Trainer

Operator overloading is allowed in C++ but not in Java since the garbage is clearance is not automatic in JAVA
Comments

Mathematics,Computer Science and Engineering

1) Simplicity and Cleanliness 2) Avoid Programming Errors 3) JVM Complexity 4) Easy Development of Tools
Comments

IT Professional Trainer with 15 years of experience in IT Industry

Java only allows arithmetic operations on elementary numeric types. It's a mixed blessing, because although it's convenient to define operators on other types (like complex numbers, vectors etc), there are always implementation-dependent idiosyncrasies. So operators don't always do what you expect them...
read more
Java only allows arithmetic operations on elementary numeric types. It's a mixed blessing, because although it's convenient to define operators on other types (like complex numbers, vectors etc), there are always implementation-dependent idiosyncrasies. So operators don't always do what you expect them to do. By avoiding operator overloading, it's more opaque which function is called when. A wise design move in some people's eyes. read less
Comments

mca

JVM doesn't support operator overloading may be because of complexity.
Comments

View 12 more Answers

Related Questions

I am a fresher and I want to become a Java developer, so what is necessary to crack the Java interview ? 

For an interview, you should prepare all the basic questions of Java , class, function and OOP concepts.
Dipesh
Which one is faster, Python or Java?
The speed of Python and Java can vary depending on the specific task. Java is generally considered faster for low-level operations and large-scale applications, while Python is often valued for its simplicity...
Chetana
0 0
5
Who can provide good Java training with real-time but not institute?
I provide industry specific training to students. If interested check my profile. I used to provide training in Big Data, Java, Scala and Spark too.
Sridevi
0 0
6

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

Java
Java is a high level language which is far better than procedural languages like C, Fortran and Pascal. Java completely stands with the principles of OOPS (Object Oriented Programming Structure). The...
A

Abhisheak Saxena

0 0
0

Java and C trainer
Always think any conspect with real-time example like Object -- object must have states and behaviour then only we will call that thing is Object like fan is Object (rotating,color)

Observer Pattern in Java.
As I was going through the different source code files of the Java Util package, I found the implementation of the Observer Pattern ( see the Gang of Four books for more information on this pattern) in...

How can everyone prepare to clear any Java interview?
Java interview your java should be much strong then J2EE. core java and Advance java is the basic foundation for Interview. Some of the topic about which you should know before going for a java interview...

Java :: Inner Class Concepts
Java:: Inner Class Concepts--------------------------------- Inner class concepts introduced in Java v1.1 - as a part of AWT Event Handling improvements.When to use Inner class: - Without existing One...
M

Marimuthu P.

2 0
0

Recommended Articles

In the domain of Information Technology, there is always a lot to learn and implement. However, some technologies have a relatively higher demand than the rest of the others. So here are some popular IT courses for the present and upcoming future: Cloud Computing Cloud Computing is a computing technique which is used...

Read full article >

Java is the most famous programming language till date. 20 years is a big time for any programming language to survive and gain strength. Java has been proved to be one of the most reliable programming languages for networked computers. source:techcentral.com Java was developed to pertain over the Internet. Over...

Read full article >

Before we start on the importance of learning JavaScript, let’s start with a short introduction on the topic. JavaScript is the most popular programming language in the world, precisely it is the language - for Computers, the Web, Servers, Smart Phone, Laptops, Mobiles, Tablets and more. And if you are a beginner or planning...

Read full article >

Java is the most commonly used popular programming language for the creation of web applications and platform today. Integrated Cloud Applications and Platform Services Oracle says, “Java developers worldwide has over 9 million and runs approximately 3 billion mobile phones”.  Right from its first implication as java 1.0...

Read full article >

Looking for Java Training Classes?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for Java Training Classes?

The best tutors for Java Training Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Java Training with the Best Tutors

The best Tutors for Java Training Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more