Core Java - Interview Questions and Answers for 'Data type' | Search Interview Question - javasearch.buggybread.com
Javasearch.buggybread.com

Search Interview Questions


 More than 3000 questions in repository.
 There are more than 900 unanswered questions.
Click here and help us by providing the answer.
 Have a video suggestion.
Click Correct / Improve and please let us know.
Label / Company      Label / Company / Text

   



Core Java - Interview Questions and Answers for 'Data type' - 38 question(s) found - Order By Rating

next 30
 Q1. What is the advantage of BidDecimal over Double ?Core Java
Ans. BigDecimal provides more precision as compared to double.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     BigDecimal  Double  data types


 Q2. In the Following code which foo will get called.

foo(Integer i){
}

foo(String s){
}

public static void main(){
passing foo(null);
}
Core Java
Ans. ambiguity error

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     code  method  function  data types     Asked in 1 Companies


 Q3. What do we mean by a Data Type ?Core Java
Ans. if you have similar type of data or objects or entities, then we can give them a type with unique name. And this name will be our Data type.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     data type


 Q4. What will be the output of following code and Why ?

int x = 5;
int y = 7;
float f = 5f;
float z = y / x * f;
System.out.println(z);
Core Java
Ans. 5.0

operation between two ints generate int only. so 7/5 generates 1 and not 1.4. Multiplication between int and float generates float and hence

1 * 5.0 = 5.0

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     arithmetic calculation  data types


 Q5. Are char,String and Char data types in java ? Core Java
Ans. char is a primitive data type. String is a class. Char is a wrapper class for primitive char.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     char  string  data type      Basic


 Q6. Is String a Data type in Java ?Core Java
Ans. String is not a primitive type in java. Anything defined within double quotes like "abc" is an object of String class.

  Sample Code for String

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     string  data type      Basic


 Q7. What is Boxing conversion ?Core Java
Ans. Boxing conversion converts expressions of primitive type to corresponding expressions of reference type.

For example

boolean to Boolean
long to Long
double to Double

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     data type  boxing  wrapper classes


 Q8. What is widening and narrowing conversion in Java ?Core Java
Ans. Conversion means that the expression / literal / value of one type getting converted to other type.

Widening conversion is the conversion from Type A to Type B where B requires a wider space than A. For example - int to long, float to double, char to String etc. As the value moves to a wider space, there is no loss of information.

Narrowing conversion is the conversion from Type A to Type B where B requires a narrower space space than A. For example - int to long, float to double, char to String etc.As the value moves to a narrower space, there is a loss of information.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     data type  widening conversion  narrowing conversion


 Q9. Difference between int and short data types ?Core Java
Ans. Both holds numeric values. short is a 16-bit signed two's complement integer whereas int is a 32-bit signed two's complement integer.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     data types  short vs int


 Q10. What are the different primitive data types in Java ?Core Java
Ans. boolean
byte
char
double
float
int
long
short
void

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     data types  primitive data types     Asked in 1 Companies      Basic


 Q11. How does Java handle integer overflows and underflows?Core Java
Ans. It uses those low order bytes of the result that can fit into the size of the type allowed by the operation.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     integer  data types     Asked in 1 Companies        rare


 Q12. Why calculations in float or Double sometimes gives unpredictable results ?Core Java
Ans. Because the way float values are stored its not precise.

For example - 0.1 is actually stored as
0.1000000000000000055511151231257827021181583404541015625

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     double  float  data type      basic        frequent


 Q13. How do you prefer to store money values in your application ?Core Java
Ans. At Application level we use either Double or BigDecimal , preferably BigDecimal. At Database level we use Number with decimal precision 3.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     data types


 Q14. What are the Wrapper classes available for primitive types ?Core Java
Ans. boolean - java.lang.Boolean
byte - java.lang.Byte
char - java.lang.Character
double - java.lang.Double
float - java.lang.Float
int - java.lang.Integer
long - java.lang.Long
short - java.lang.Short
void - java.lang.Void

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   java5   data types   wrapper classes   adapter design pattern        rare


 Q15. Difference between long.Class and Long.TYPE ?
Ans. They both represent the long primitive type. They are exactly the same.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   data types   long.Class   long.TYPE   advanced      expert        rare


 Q16. What are wrapper classes ?Core Java
Ans. They are wrappers to primitive data types. They allow us to access primitives as objects.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   data types   wrapper classes     Asked in 3 Companies      basic        frequent


  Q17. What is casting?Core Java
Ans. There are two types of casting, casting between primitive numeric types and casting between object references. Casting between numeric types is used to convert larger values, such as double values, to smaller values, such as byte values. Casting between object references is used to refer to an object by a compatible class, interface, or array type reference

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   data types   casting  type casting   basic interview question     Asked in 8 Companies      basic        frequent


 Q18. What are the default or implicitly assigned values for data types in java ?
Ans. boolean ---> false
byte ----> 0
short ----> 0
int -----> 0
long ------> 0l
char -----> /u0000
float ------> 0.0f
double ----> 0.0d
any object reference ----> null

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   data types   default values

Try 1 Question(s) Test


 Q19. What is the difference between float and double?
Ans. Float can represent up to 7 digits accurately after decimal point, where as double can represent up to 15 digits accurately after decimal point.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   data types   float   double   difference between   basic interview question


 Q20. What is Generalization and Specialization in terms of casting ?Core Java
Ans. Generalization or UpCasting is a phenomenon where a sub class is prompted to a super class, and hence becomes more general. Generalization needs widening or up-casting. Specialization or DownCasting is a phenomenon where a super class is narrowed down to a sub class. Specialization needs narrowing or down-casting.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   data types   casting  type casting   up casting  type casting   downcasting  type casting   generalization   specialization     Asked in 2 Companies


 Q21. What data type Variable can be used in a switch statement ?Core Java
Ans. Variables used in a switch statement can only be a byte, short, int, or char ( and String with Java 7 and above )

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   switch   variable   data type      basic        rare


 Q22. Variable of the boolean type is automatically initialized as?Core Java
Ans. The default value of the boolean type is false.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   data type   boolean   initialization   default object construction   default constructor   default value


 Q23. Name few classes that extends Number Class ?
Ans. http://www.buggybread.com/2015/02/java-util-classes-that-inherit-number.html

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   data types   number class


 Q24. Name few Boolean classes and interfaces ?
Ans. http://www.buggybread.com/2015/01/java-data-types-double-classes-and_31.html

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   data types   boolean


 Q25. Name few Double data types related classes and interfaces ?
Ans. http://www.buggybread.com/2015/01/java-data-types-double-classes-and.html

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   data types   double


 Q26. Name few float data type related classes and interfaces ?
Ans. http://www.buggybread.com/2015/01/java-data-types-float-classes-and.html

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   data types   float


 Q27. Name few Integer related classes and interfaces ?
Ans. http://www.buggybread.com/2015/01/java-data-types-integer-classes-and.html

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   data types   integer


 Q28. Name few long data type related classes and interfaces ?
Ans. http://www.buggybread.com/2015/01/java-data-types-long-classes-and.html

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   data types   long


 Q29. What is the difference between Data Type and Data Structure ?Core Java
Ans. Data type: a set of values together with operations on that type
Data structure: a physical implementation of a data type

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   oops   data structure   data type


 Q30. Is it correct to say that Interfaces are abstract data types ?
Ans. No.

Data Type holds data whereas Interface doesn't hold anything. Interface is a contract about how to communicate with the underlying Class.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   interface   data type


next 30

Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked: