Explain when and where one should use all the different data types while creating variables?

738    Asked by VaibhavMishra in QA Testing , Asked on Dec 28, 2019
Answered by Ashish Mishra

As we know there are different data types and while you are learning data types in order to learn a new language, one should be aware of when to use them and how.

Different data types are: int, short, Boolean, long, double, char, float, String, byte to name a few.  

  1. If you are declaring numeric values, you can use any of this depending upon your need and precision: int/short/long/double/float/byte. 
  2. If you are declaring a variable with answer to it as Yes/No, true/False, 0/1, in this case you need to make the data type of variable as Boolean. 
  3. If you need to store some text, in that case you can use, String or char to define your variable. 



Your Answer

Interviews

Parent Categories