

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Downcasting in Java
Yes, a variable can be downcast to its lower range substitute by casting. It may lead to data loss although. See the example below −
Example
public class Tester { public static void main(String[] args) { int a = 300; byte b = (byte)a; System.out.println(b); } }
Output
It will print output as
44
- Related Questions & Answers
- Java Stream Collectors toCollection() in Java
- Java program to calculate mode in Java
- Compare Two Java int Arrays in Java
- Convert Java String to Short in Java
- Greedy quantifiers Java Regular expressions in java.
- Is Java matcher thread safe in Java?
- Programming in Java.
- Inheritance in Java
- Loops in Java
- Polymorphism in Java
- Abstraction in Java
- Interface in Java
- Packages in Java
- Aggregation in Java
- Encapsulation in Java
Advertisements