A directory of Objective Type Questions covering all the Computer Science subjects. Here you can access and discuss Multiple choice questions and answers for various compitative exams and interviews.

31. Which among the following is true for upcasting in inheritance?
a. Downward to the inheritance tree
b. Upward to the inheritance tree
c. Either upward or downward
d. Doesn’t apply on inheritance
View Answer Report Discuss Too Difficult!
Answer: (b).Upward to the inheritance tree

32. Which among the following is safe?
a. Upcasting
b. Downcasting
c. Both upcasting and downcasting
d. If upcasting is safe then downcasting is not, and vice versa
View Answer Report Discuss Too Difficult!
Answer: (a).Upcasting

33. Which among the following is best situation to use upcasting?
a. For general code dealing with only subtype
b. For general code dealing with only supertype
c. For general code dealing with both the supertype and subtype
d. For writing a rigid code with respect to subtype
View Answer Report Discuss Too Difficult!
Answer: (b).For general code dealing with only supertype

34. Which property is shown most when upcasting is used?
a. Code reusability
b. Code efficiency
c. Complex code simple syntax
d. Encapsulation
View Answer Report Discuss Too Difficult!
Answer: (c).Complex code simple syntax

35. Upcasting and downcasting objects is same as casting primitive types.
a. True
b. False
c. May be
d. Can't say
View Answer Report Discuss Too Difficult!
Answer: (b).False

36. Which casting among the following is allowed for the code given below?
class A
{
 public :int a;
}
class B:public A
{
 int b;
}
main()
{
 B b=new A();  //casting 1
 A a=new B();  //casting 2
}
a. Casting 1
b. Casting 2
c. casting 1 and casting 2
d. casting 1 nor casting 2
View Answer Report Discuss Too Difficult!
Answer: (b).Casting 2

37. If multiple inheritance is implemented, which upcasting will be correct?
a. Upcast to first base class listed in inheritance
b. Upcast to send base class listed in inheritance
c. Upcast to any base class
d. Upcast is not possible
View Answer Report Discuss Too Difficult!
Answer: (c).Upcast to any base class

38. If class C inherits class B and class B inherits class A ________________
a. Class C object can be upcasted to object of class B only
b. Class C object can be upcasted to object of class A only
c. Class C object can be upcasted to object of either class A or B
d. Class C object can’t be upcasted
View Answer Report Discuss Too Difficult!
Answer: (c).Class C object can be upcasted to object of either class A or B

39. Upcasting is _____________________ without an explicit type cast.
a. Always allowed for public inheritance
b. Always allowed for protected inheritance
c. Always allowed for private inheritance
d. Not allowed
View Answer Report Discuss Too Difficult!
Answer: (a).Always allowed for public inheritance

40. Which concept is needed because of implicit type casting use?
a. Static binding
b. Dynamic binding
c. Compile time binding
d. Source code binding
View Answer Report Discuss Too Difficult!
Answer: (b).Dynamic binding

Page 4 of 6