---
title: "What happen if we print an object in java"  
description: "What happen if we print an object in java"  
author: "Anonymous User"  
published: 2015-09-22  
updated: 2020-09-22  
canonical: https://www.mindstick.com/interview/22836/what-happen-if-we-print-an-object-in-java  
category: "java"  
tags: ["java"]  
reading_time: 1 minute  

---

# What happen if we print an object in java

```
A a = new A();System.out.println(a);
```

It will call the toString() method of that class, if the method is not present in that class, it will look for toSting() method in super class, if its not there, then it will call Object's class toString() method which would give you the memory location (hexadecimal representation) of that object.


---

Original Source: https://www.mindstick.com/interview/22836/what-happen-if-we-print-an-object-in-java

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
