C | C++ | Java Interview Questions and Answers - 2

Question: 6

What are wrapper classes?

Wrapper classes are classes that allow primitive types to be accessed as objects.

Question: 7

What is the difference between integer and int?

Integer is a class defined in the java.lang package, whereas int is a primitive data type defined in the Java language itself. Java does not automatically convert from one to the other.

Integer can be used as an argument for a method that requires an object, whereas int can be used for calculations.

Question: 8

What is unicode?

Unicode is used for internal representation of characters and strings and it uses 16 bits to represent each other.

Question: 9

What are the drawbacks of inheritance?

Since inheritance inherits everything from the super class and interface, it may make the subclass too clustering and sometimes error prone when dynamic overriding or dynamic overloading in some situation.

In addition, the inheritance may make peers hardly understand your code if they don’t know how your super class acts.

Usually, when you want to use a functionality of a class, you may use subclass to inherit such function or use an instance of this class in your class.

Question: 10

What is casting?

Casting is used to convert the value of one type to another.

Related Questions