:: Home Page            
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Categories >> Software >> Java Related >> Java J2EE >> Core Java


 Core Java interview questions  Core Java Interview Questions (1728)
 Advanced Java interview questions  Advanced Java Interview Questions (332)
 Swing interview questions  Swing Interview Questions (44)
 EJB interview questions  EJB Interview Questions (134)
 Servlets interview questions  Servlets Interview Questions (255)
 Struts interview questions  Struts Interview Questions (196)
 JDBC interview questions  JDBC Interview Questions (187)
 JMS interview questions  JMS Interview Questions (9)
 SunOne interview questions  SunOne Interview Questions (3)
 J2EE interview questions  J2EE Interview Questions (71)
 Weblogic interview questions  Weblogic Interview Questions (147)
 Websphere interview questions  Websphere Interview Questions (14)
 Java Networking interview questions  Java Networking Interview Questions (20)
 Java J2EE AllOther interview questions  Java J2EE AllOther Interview Questions (87)
what is object type casting? give some example with related?
 Question Submitted By :: Core-Java
I also faced this Question!!     Answer Posted By  
# 1
In java object typecasting one object reference can be type
cast into another object reference. The cast can be to its
own class type or to one of its subclass or superclass types
or interfaces. There are compile-time rules and runtime
rules for casting in java.
Consider an interface Vehicle, a super class Car and its
subclass Ford. The following example shows the automatic
conversion of object references handled by the compiler

interface Vehicle {
class Car implements Vehicle {

class Ford extends Car {

Let c be a variable of type Car class and f be of class Ford
and v be an vehicle interface reference. We can assign the
Ford reference to the Car variable:
I.e. we can do the following

'''Example 1
c = f; //Ok Compiles fine'''

Where c = new Car();
And, f = new Ford();
The compiler automatically handles the conversion
(assignment) since the types are compatible (sub class -
super class relationship), i.e., the type Car can hold the
type Ford since a Ford is a Car.
Is This Answer Correct ?    6 Yes 0 No
# 2
Object type casting is converting a object type into another
type. For example

Iterator ite = emplist.iterator();

Employee empObj = (Employee);


Here returns instance of type Object, we need to
convert it to type Employee so this is called type casting.
Is This Answer Correct ?    5 Yes 0 No

Other Core Java Interview Questions
  Question Asked @ Answers
Difference between an argument and a parameter? HCL 10
Hi Friends, can you explain instance in java. In general instance means "occurence of something" . In java what is instance.   4
What are the notations in Java? Cap-Gemini 1
When does the compiler supply a default constructor for a class? TCS 9
what is difference between servletconfig and servletcontext? AMDOC 3
explain the classification of exception and hoew to handle the exceptions   2
What is the root class for all Java classes? Infosys 8
where u use Abstraction and Interface in real time Sonata 3
Explain the differences between public, private, protected and static?   4
How to sort a vector elements that contains the user define class object? (Note: If Suppose consider, A Student class contain two data members. They are String studentName and int rollNo. I am creating Four objects for this class, each object contains students details like name and roll no. Now i am storing that objects in vector and if i retiving the elements from the vector means then it should be display in sorting order) ProdEx-Technologies 3
what is difference between method overloading & method overridding with example? IBM 4
what is difference Between Core Java and advance java HCL 59
For more Core Java Interview Questions Click Here 

Copyright Policy  |  Terms of Service  |  Articles  |  Site Map  |  RSS Site Map  |  Contact Us
Copyright 2013  All Rights Reserved.   ::