Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


What is Unit in Scala? What is the difference between Java’s void and Scala’s Unit?



What is Unit in Scala? What is the difference between Java’s void and Scala’s Unit?..

Answer / Pappu Kumar Choudhary

Unit is a special type in Scala, similar to void in Java, but they have some differences. While void in Java signifies the absence of a return value for a method, Scala's Unit represents an empty value (similar to Null or Nothing in other languages). The key difference is that Scala functions always implicitly return Unit if no return type is specified, while Java methods with a return type of void explicitly state that they don't return any value.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Scala Interview Questions

What language is scala written in?

1 Answers  


How to install scala? Explain

1 Answers  


What is lambda expression in scala?

1 Answers  


Explain how scala is both functional and object-oriented programming language?

1 Answers  


Difference between Array and List in Scala?

1 Answers  


What is Diamond Problem? How Scala solves Diamond Problem?

1 Answers  


What is scala closure?

1 Answers  


What are the advantages of scala over java (java 8)?

1 Answers  


What is formula tail in scala?

1 Answers  


Explain the operators in scala?

1 Answers  


Why scala prefers immutability?

1 Answers  


What is the use of 'object' keyword in Scala? How to create Singleton objects in Scala?

1 Answers  


Categories