Enter your keyword




In computer programming, a primitive (pronounced PRIH-muh-teev ) is a basic interface or segment of code that can be used to build more sophisticated program elements or interfaces.


Primitive Data Types:
byte a = 68;
char a = 'A' int decimal = 100;
int octal = 0144;
int hexa = 0x64;
"Hello World"
"two\nlines"char a = '\u0001';
String a = "\u0001";
"\"This is in quotes\""

Commonly asked interview questions on Constructors

1. What are the Wrapper classes available for primitive types ?

Answer :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

2. Difference between long.Class and Long.TYPE ?

Answer : They both represent the long primitive type. They are exactly the same.

3. What are Wrapper Classes ? What are Primitive Wrapper Classes ?

Answer : A wrapper class is any class which “wraps” or “encapsulates” the functionality of another class or component. A Wrapper Class that wraps or encapsulates the primitive data type is called Primitive Wrapper Class.

4. What is casting?

Answer :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

5. Does Declaring an object “final” makes it immutable ?

Answer :Only declaring primitive types as final makes them immutable. Making objects final means that the object handler cannot be used to target some other object but the object is still mutable.

Take Sample Test

Reference Books

1. Head First Java

No Comments

Add your review

Your email address will not be published.