Hello Friends, In this Blog Post I am going to let you know about a few more interview questions of core java related to Type Casting.
Core java interview questions covers all the important questions of the topics mentioned above.
These core java interview questions is a great help to remember all the important highlights and important topics from each java chapter.
These interview questions will surely help to understand a few very confusing concepts in java.
What is the difference between primitive data types and advanced data types?
Primitive data types represent single values. Advanced data types represent a group of values. Also, methods are not available to handle primitive data types.
In the case of advanced data types, methods are available to perform various operations.
What is implicit casting?
Automatic casting done by java compiler internally is called implicit casting, implicit casting is done to convert lower data types into higher data types.
What is explicit casting?
The casting done by a programmer is called explicit casting. Explicit casting is compulsory while converting from a higher data type to a lower data type.
What is generalization and specialization?
Generalization is a phenomenon where a subclass is promoted to a superclass, and hence become more general. Generalization needs widening or up-casting.
Specialization is a phenomenon where a superclass is narrowed down to a subclass. Specialization needs narrowing or down-casting.
What is widening and narrowing?
Converting lower data type to higher data type is called widening and converting a higher data type to a lower data type is called narrowing.
Widening is safe and hence even if the programmer does not use a cast operator, the java compiler does not flag any error. The narrowing is unsafe and hence the programmer should explicitly use cast operators in narrowing.
Which is the superclass for all the classes including your classes?
Object class is the super class of all the classes.
Which method is used in cloning?
Clone() method of object class is used in cloning.
Can you write an interface without a method?
Yes, you can write it.
What do you call an interface without any member?
An interface without any member is called a marking interface or tagging interface. It marks the class objects for a special purpose. For example, cloneable(java.lang) and serializable(java.io) are two marking interface.
Cloneable interface indicates that particular class objects are cloneable while serializable interface indicates that particular class objects are serializable.
So this was all about the Core java interview questions in this topic.
These Core java interview questions could be a great help in your college viva, academic study, and any job interview.
In the case of any queries, you can write to us at [email protected] we will get back to you ASAP.
Hope! you would have enjoyed this post about Core Java Interview Questions Part 12/Type Casting.
Please feel free to give your important feedbacks in the comment section below.
Have a great time!