Object Casting Polymorphism Interview Questions

Note: Explanation is given avoiding more buzz words. Easily understandable manner.

    Object Casting Polymorphism Interview Questions
  1. What is casting?
    Converting one data type (or object) to the other is known as casting. It is required in a programming language as the user entered data may be in different form than required in coding.
  2. How many types of casting exists in Java?
    There are two types of casting – Primitive data type casting and Object casting (string to data type conversion is not casting).
  3. How many types of primitive data type casting exist in Java?
    Three types – implicit casting, explicit casting and boolean casting.
  4. How many types of object casting exist in Java?
    Two types – implicit casting and explicit casting.
  5. What are data type casting rules?
    1. A data type of lower size (occupying less memory) can be assigned to a data type of higher size implicilty (done by JVM automatically).
    2. But the converiosn of data type of higher size to lower size requires explicit conversion (should be done by programmer himself).
  6. What are object casting rules?
    1. Object of the same class can be assigned to one another and is done implicilty.
    2. A subclass object can be assigned to a super class object and is done implicitly.
    3. A super class object cannot be assigned to a subclass object, and still to do, requires explicit casting.
  7. What is dynamic method dispatch or dynamic binding?
    Decision of which method is to be sent for execution at runtime is known as dynamic method dispatch or dynamic binding (remember, Java achieves static binding through method overloading).
  8. How Java achieves dynamic polymorphism?
    Java achieves dynamic polymorphism through method overriding and object casting.

Pass your comments on suggestions on this tutorial on "Object Casting Polymorphism Interview Questions" to improve the quality.

2 thoughts on “Object Casting Polymorphism Interview Questions”

  1. Respected Sir,

    Thank you so much for you. I read your book i learn many knowledge 1000 time thanks for you. and also I have one doubt.

    public static void main(String args[])
    public static void main(String… args) what is the difference between and also i use two dots compile time error will occur. please clear my doubts.

    I need jsp, servlet, Bean , rmi, spring , struts, hibernet,spring, weblogics,Ejb, these concepts i dont have any notes i need it plese send me you have. you publish any advanced java book tell your book name i buy it.

    G.Palanikumar

Leave a Comment

Your email address will not be published.