CS 2110 Midterm: CS 2110 Cornell 2012 Fall Examsp2solggcs211Fall 04

39 views14 pages
31 Jan 2019
Course
Professor

Document Summary

Nal public string getvalue () { return getx(). value; Nal public void setvalue (string value) { getx (). value = value; Nal public string getname () { return x. name; Nal public void setname (string name) { x. name = name; protected pair getx () { return x; public class b extends a { 2 private pair x; public b (string value) { super(value); protected pair getx () { return x; String result = a. x. name == + a. getname() + , + A. 1) what is the return value of the following function invocation: test (new b( foo )) ? (7 points) A. 1) solution: the execution will halt with a null pointer exception in the call to a. setvalue, because getx() will return b. x which is null. A. 2) write a class c such that the result of invoking the function test (new c()) is the string: Recall that you cannot override nal methods in sub-classes. (7 points) A full credit solution: class c extends a.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers

Related Questions