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

What are the different types of Exceptions in Java?
Null pointer exception ArrayOutOfIndex exception DivideByZero exception
Aakanksha
simple way to explane the servlet in java
Servlet is a program wich executed in server and assists in responding to client queries..... Usually confidential tasks are done by using servlets or other server side codes
Anish
What are the advanced Java topics?
Mainly divided in three parts JDBC,SERVLET,JSP and each one contains multiple sub topics
Ganesh
0 0
5

What do you understand by Object and Class?

A class provides the blueprints for objects. So basically, an object is created from a class. That can be used anywhere as you wish.
Afsal

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: A Quick Overview
Not purely Object Oriented: It doesn't support multiple inheritence, it supports primitive data types and static members. Doesn’t support multiple inheritance: Reason is diamond problem i.e.,...

Introduction to Programming Languages
What is a Programming Language? A programming language is a formal computer language or constructed language designed to communicate instructions to a machine, particularly a computer. Programming languages...

Android : Application Launch time improvements.
For any standard android application, below 3 components play important roles to show 1st interface to user, so that he/she can interact with the app. 1. Custom Application class : Intialize the components...


Java Collection
Collection: The collection provides an architecture like a list where we can store and manipulate the group of items. Through Collections, we can achieve operations such as searching, sorting, insertion,...

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