Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Swift Question 1) Assume that A is a superclass of B. Choose all the following declarations that are legal. A) var a: A = A()

Swift Question

1) Assume that A is a superclass of B. Choose all the following declarations that are legal.

A) var a: A = A()

B) var a: A = B()

C) var b: B = A()

D) var b: B = B()

2) Assume that A is s superclass of B. Variable obj is declared to be of type A. Which of the following is the correct syntax to downcast obj to type B and call a method m defined in B but not in A.

A) obj.m()

B) (obj as! B).m()

C) (obj as? B).m()

D) B(obj).m()

F) None of the above

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions