What will be the result of compiling and running the following program? Select the one correct answer.
Question:
What will be the result of compiling and running the following program?
Select the one correct answer.
(a) The program will fail to compile.
(b) The program will compile, and print 0 when run.
(c) The program will compile, and print 1 when run.
(d) The program will compile, and print 2 when run.
(e) The program will compile, and print 3 when run.
Transcribed Image Text:
public class Polymorphism2 { public static void main(String [] args) { A refl= new C (); B ref2 = (B) refl; System.out.println (ref2.g ()); } } class A { private int f() { return 0; } public int g() { return 3; } } class B extends A ( private int f() { return 1; } public int g() { return f(); } } class C extends B ( public int f() { return 2; } }
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 100% (2 reviews)
c The program will print 1 when run The f methods in A and B are private and ...View the full answer
Answered By
Chanderket Kumar
Has worked with multiple Govt. Agencies such as "National Human Rights Commission " (NHRC) and V.V. Giri National Labour Institute Under the supervision Of Ministry Of Social Justice and Empowerment, Also has worked closely with Delhi Police and Department of Justice and Law as an intern, Have a Field Experience of Prison/Jail Visit and how the Courts Function. Has worked on Dozens of research papers including Ecology And Society, Understanding Max Weber State Concerning Armed Forces Special Power Act (AFSPA), Understanding the 6th Schedule of Constitution Of India, Peace and Conflict Resolution Regarding Indo-Pak relations post-Vajpayee Era, Understanding dominant cast in Indian society, Role of Trade Union in India, Etc.
0.00
0 Reviews
10+ Question Solved
Related Book For
Programmers Guide To Java SE 8 Oracle Certified Associate OCA
ISBN: 9780132930215
1st Edition
Authors: Khalid Mughal, Rolf Rasmussen
Question Posted:
Students also viewed these Computer science questions
-
In Problems 1 through 10, we have provided the slope field of the indicated differential equation, together with one or more solution curves. Sketch likely solution curves through the additional...
-
In Problems 1 through 10, we have provided the slope field of the indicated differential equation, together with one or more solution curves. Sketch likely solution curves through the additional...
-
Fill in each blank so that the resulting statement is true. Consider the following system: Equation 2 does not contain the variable_______ . To obtain a second equation that does not contain this...
-
Benny sells an apartment building. His adjusted basis for regular income tax purposes is $450,000, and it is $475,000 for AMT purposes. He receives $700,000 from the sale. a. Calculate Bennys gain...
-
Three point charges are located at the corners of an equilateral triangle as shown in Figure P23.7. Calculate the resultant electric force on the 7.00-μC charge. 7.00 uC 0.50 m 60 2.00
-
The primacy and recency effects that occur in the serial position curve have been linked to long-term memory and short-term memory, respectively. L01
-
4. Reserve for encumbrance accounts in general fund balance sheets at year-end indicate: a The amount of net position required to complete the transaction(s) in the succeeding period b Noncompliance...
-
This problem continues the Draper Consulting, Inc., situation from Problem 12-45 of Chapter 12. In October, Draper has the following transactions related to its common shares: Oct 1 Draper...
-
Porter Company is analyzing two potential investments. The payback period in years (rounded to 2 decimal placesi for Project X is: Multiple Choice 2.00 3.95. 3.41 2.95. 3.80
-
The director of laboratory services at Henry Hospital is assessing her staffing requirements. The hospital processes 1,440,000 lab tests per year. A lab tech can process 50 per day and earns $50,000...
-
Which statements about the following program are true? Select the three correct answers: (a) The code will fail to compile. (b) The code defines a Planet is-a Star relationship. (c) The code will...
-
What will be the result of compiling and running the following program? Select the one correct answer. (a) The program will fail to compile. (b) The program will compile, but will throw a...
-
The following facts pertain to a non-cancelable lease agreement between Alschuler Leasing Company and McKee Electronics, a lessee, for a computer system. Commencement date ? ? ? ? ? ? ? ? ? ? ? ? ? ?...
-
Consider a system consisting of a colloidal particle of radius and charge Q-+20e (e is the charge of an electron) stationary in the center of a spherical cavity of radius R=5. Its counterions have...
-
Use the Empirical Rule to determine the percentage of candies with weights between 0.7 and 0.98 gram. Hint: x=0.84.
-
A sample of 16 items provides a sample standard deviation of 9.5. Test the following hypotheses using a = .05. Ho: 0250 2 Ha > 50 a. Calculate the value of the test statistic (to 2 decimals). 27.08...
-
During May, Darling Company incurred factory overhead costs as follows: indirect materials, $1,170; indirect labor, $2,000; utilities cost, $1,270; and factory depreciation, $5,850. Journalize the...
-
Practice 1 Let f(0) = cos(0). For each interval in the table below, determine the characteristics of f(e) Positive or negative Increasing or decreasing Concave up or concave down Let g(0) = 00
-
Find two lines in R3 which are not parallel but do not intersect.
-
In the simple quantity theory of money, what will lead to an increase in aggregate demand? In monetarism, what will lead to an increase in aggregate demand?
-
Give a justification of the running times shown in Table 7.1 for the methods of an array list implemented with a (nonexpanding) array.
-
Consider the implementation of CircularlyLinkedList.addFirst, in Code Fragment 3.16. The else body at lines 39 and 40 of that method relies on a locally declared variable, newest. Redesign that...
-
Isabel has an interesting way of summing up the values in an array A of n integers, where n is a power of two. She creates an array B of half the size of A and sets B[i] = A[2i]+ A[2i+ 1], for i =...
-
An underlying asset price is at 100, its annual volatility is 25% and the risk free interest rate is 5%. A European call option has a strike of 85 and a maturity of 40 days. Its BlackScholes price is...
-
Prescott Football Manufacturing had the following operating results for 2 0 1 9 : sales = $ 3 0 , 8 2 4 ; cost of goods sold = $ 2 1 , 9 7 4 ; depreciation expense = $ 3 , 6 0 3 ; interest expense =...
-
On January 1, 2018, Brooks Corporation exchanged $1,259,000 fair-value consideration for all of the outstanding voting stock of Chandler, Inc. At the acquisition date, Chandler had a book value equal...
Study smarter with the SolutionInn App