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

Search Java Interview Questions


 2137 questions in repository.
 There are more than 200 unanswered questions.
Click here and help us by providing the answer.
Label / Company      Label / Company / Text

   



Interview Questions and Answers for 'Data type' - 37 question(s) found - Order By Newest

 Q1. What is Generalization and Specialization in terms of casting ?Core Java
Admin
info@buggybread.com
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   up casting   downcasting   generalization   specialization     Tata Consultancy (TCS)  VirtusaPolaris


 Q2. Why Java is not considered pure OOP's language ?Core Java

Ans. There are 2 reasons for it.

1. Usage of Primitive types - Though Java provides classes for the primitive data types but as the usage of primitives is permissible, its considered unpure OOP's language.

2. Usage of Static members - Static members belong to the class and not objects and hence not considered fit for pure OOP's programming.

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

   Like      Discuss      Correct / Improve     oops  object oriented programming  object oriented language  primitive data types     BSL Information Technology  Data64


 Q3. What are the Wrapper classes available for primitive types ?Core Java
Anonymous
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


 Q4. What are wrapper classes ?Core Java
Anonymous
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     CSL  Xoriant  Webilent      basic        frequent


  Q5. What is casting?Core Java
Anonymous
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   basic interview question     Mindtree  HCL Technologies  Wipro  Tata Consultancy (TCS)  Infosys  KPMG      basic        frequent


 Q6. What are the default or implicitly assigned values for data types in java ?
Anonymous
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


 Q7. Difference between long.Class and Long.TYPE ?
Anonymous
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


 Q8. What is the difference between float and double?
Admin
info@buggybread.com
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


 Q9. What data type Variable can be used in a switch statement ?Core Java
Admin
info@buggybread.com
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



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



 Q10. Variable of the boolean type is automatically initialized as?Core Java
Admin
info@buggybread.com
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


 Q11. Name few classes that extends Number Class ?
Admin
info@buggybread.com
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


 Q12. Name few Boolean classes and interfaces ?
Admin
info@buggybread.com
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


 Q13. Name few Double data types related classes and interfaces ?
Admin
info@buggybread.com
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


 Q14. Name few float data type related classes and interfaces ?
Admin
info@buggybread.com
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


 Q15. Name few Integer related classes and interfaces ?
Admin
info@buggybread.com
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


 Q16. Name few long data type related classes and interfaces ?
Admin
info@buggybread.com
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


 Q17. What is the difference between Data Type and Data Structure ?Core Java
Admin
info@buggybread.com
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


 Q18. Is it correct to say that Interfaces are abstract data types ?
Admin
info@buggybread.com
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


 Q19. Do you see Class as a Data Type or Data Structure ?
Admin
info@buggybread.com
Ans. Class can be better seen as Data Type. This could be implemented as a Data Structure too in some cases.

One thing worth understanding here is that Data type and Data structure are conceptual things. Class could be implementation of either of these.

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

   Like      Discuss      Correct / Improve     java   oops   class   data type   data structure



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



 Q20. Which of the following data type you will prefer to store price - BigDecimal or Double ?
Admin
info@buggybread.com
Ans. BigDecimal if memory and Performance is not critical concern, otherwise double.

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

   Like      Discuss      Correct / Improve     java   data types   double   bigdecimal


 Q21. Which takes more memory - float or Float ?Core Java
Admin
info@buggybread.com
Ans. float is a native data type whereas Float is a class. A Float object will always take more memory than float variable as there are metadata overheads with the objects.

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

   Like      Discuss      Correct / Improve     java   data type   float     SPAN Infotech  Mindtree  Camerinfolks      basic        frequent


 Q22. What is the size of long data type ?

a. 16 bit
b. 32 bit
c. 64 bit
d. 128 bit
Anonymous
Ans. 64 bit

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

   Like      Discuss      Correct / Improve     java   data types


 Q23. What is the size of double type ?

a. 16 bit
b. 32 bit
c. 64 bit
d. 128 bit
Anonymous
Ans. 64 bit

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

   Like      Discuss      Correct / Improve     java   data types


 Q24. What is the size of short type ?

a. 8 bit
b. 16 bit
c. 32 bit
d. 128 bit
Anonymous
Ans. 16 bit

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

   Like      Discuss      Correct / Improve     java   data types


 Q25. What is ADT or Abtstract Data Type ?Core Java

Ans. ADT is a container which holds different types of objects with specifications.

For example - Stack, Array, Liked list, Tree

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

   Like      Discuss      Correct / Improve     data types  abstract data types


 Q26. How do you prefer to store money values in your application ?Core Java2016-11-15 09:38:25

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


 Q27. Why calculations in float or Double sometimes gives unpredictable results ?Core Java2016-11-21 11:26:07

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


 Q28. How does Java handle integer overflows and underflows?Core Java2017-01-12 11:18:41

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     HCL Technologies        rare


 Q29. What are the different primitive data types in Java ?Core Java2017-01-28 15:14:23

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      Basic



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



 Q30. Difference between int and short data types ?Core Java2017-03-24 09:15:23

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


 Q31. What is widening and narrowing conversion in Java ?Core Java2017-06-06 12:30:31

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


 Q32. What is Boxing conversion ?Core Java2017-06-06 12:31:36

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


 Q33. Is String a Data type in Java ?Core Java2017-06-18 18:04:10

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


 Q34. Are char,String and Char data types in java ? Core Java2017-06-18 18:05:30

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


 Q35. 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 Java2017-07-23 20:00:12

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


 Q36. What do we mean by a Data Type ?Core Java2017-08-08 15:15:15

 This question is still unanswered. Can you please provide an answer.


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

   Like      Discuss      Correct / Improve     data type


 Q37. What will be the output of following ?

public class BuggyBread {

   private int x;
   private Integer y;

   BuggyBread(int x,int y){};

   public static void main(String[] args){
      BuggyBread buggybread = new BuggyBread(1,2);
      System.out.println(buggybread.x);
      System.out.println(buggybread.y);
   }
}
Core Java
a. 0 0
b. 0 null
c. null 0
d. null null

Ans.b. 0 null



Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner



comments powered by Disqus
 

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:
         

X Close this

X Close this

Help Us Improve.
Please share your
interview experience.

Company Name:   


Questions Asked: