COE 318 Quiz: COE318 – Fall 2014 Quiz-v1 (Solutions)

39 views5 pages

Document Summary

What will be the output when the following program is executed? public class ex2 { public static void main(string[] args) { Ex1 s = new ex1(11); s = q; p = s; p = null; s = r; Null reference id: 5 id: 7 id: 9 id: 11. A capacitor with charge q, voltage v and capacitance c (whose value cannot change once initialized) is characterized with the equation (cid:1843)(cid:3404)(cid:1829)(cid:1848). Its energy, u, can be calculated with (cid:1847)(cid:3404)(cid:2869)(cid:2870)(cid:1843)(cid:1848). public class capacitor { //instance variables private double capacitance; private double charge; public capacitor(double c) { capacitance = c; public double getcapacitance() { return capacitance; public double getcharge() { //complete this method return charge; public void setcharge(double newcharge) { //complete this method charge = newcharge; public double getvoltage() { //complete this method return charge/capacitance; public void setvoltage(double voltage) { //complete this method charge = capacitance * voltage; public double getenergy() { //complete this method return (1/2) * charge * getvoltage();

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 Documents