Answered step by step
Verified Expert Solution
Question
1 Approved Answer
ClassA private int i = 10; In this last exercise, first, take a look at ClassA and Class B given below. blic class publiclass
ClassA private int i = 10; In this last exercise, first, take a look at ClassA and Class B given below. blic class publiclass { ClassB : ClassA public override double Division int j) { protected int Sum (int 1) retum (double )i / j; { } retum i + j; } public void PrintResults( int 1) { publiant Product int j) Console WriteLine( "i: {0}", i); { Console W riteLine( retum i * j; Console WriteLine( } Console.WriteLine( "Sum (1): {0}" "Product(1): {0}" "Division(): {0}" , Product()); , Division (j)); Sum (i)); } public virtual double Division int j) } { retum ij } Now, explore the following code snippet that is to be a part of the Main method ClassA a = new ClassA (); ClassB b = new ClassB (); Console.WriteLine( Console.WriteLine( Console.WriteLine( Console.WriteLine( Console.WriteLine( Console.WriteLine( "Sum by class A : {0}" , a Sum (3)); "Product by class A: {0}" "Division by class A: {0}" "Sum by class B: {0}" "Product by class B: {0}" "Division by class B: {0}" , a Product(3)); , a Division (3)); b Sum (3)); , b Product(3)); , bDivision (3)); b PrintResults (3); There are multiple compilation errors relatedto this code and the implementationof ClassA and ClassB. Your task is to find all existing issues and answer the questions listed below. Try first to figure out the errors from the pictures, then transfer the code to your IDE to run it to confirm your guess. Does b, the instance of ClassB, have an instance variable i accessible? Is the first call to Console WriteLine in Print Results in Class B legal? in PrintResults in Class B legal? Is the second call to Console WriteLine Fix the program code of the snippet and the classes to make the program compilable. Run the program to get outputin the terminal. Explore the outputand explain the difference in the behaviour of the two classes.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started