You are given the below Java code: public class student{ public string name; 3: 4: 5: 6: 7: 8: 9: 10: } 11: 12: public class Mainclass{ 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: public class...


You are given the below Java code:<br>public class student{<br>public string name;<br>3:<br>4:<br>5:<br>6:<br>7:<br>8:<br>9:<br>10: }<br>11:<br>12: public class Mainclass{<br>13:<br>14:<br>15:<br>16:<br>17:<br>18:<br>19:<br>20:<br>21:<br>22:<br>public class Graduatestudent extends student{<br>public int age;<br>public void printName (){<br>System. out. print In(name);<br>public static void main(string[] args){<br>student A - new Graduatestudent ();<br>student B - new Student ();<br>Graduatestudent c - (Graduate student) A;<br>Graduatestudent D - (Graduate student) B;<br>Graduatestudent E = new Graduatestudent ();<br>A. printName();<br>E. printNameO;<br>c) Which line in the above code would result in a ClassCastException<br>d) Which line in the above code would generate a compile error.<br>e) Please give the corrected version of the line that causes the compile error.<br>.............<br>1234 567 801<br>

Extracted text: You are given the below Java code: public class student{ public string name; 3: 4: 5: 6: 7: 8: 9: 10: } 11: 12: public class Mainclass{ 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: public class Graduatestudent extends student{ public int age; public void printName (){ System. out. print In(name); public static void main(string[] args){ student A - new Graduatestudent (); student B - new Student (); Graduatestudent c - (Graduate student) A; Graduatestudent D - (Graduate student) B; Graduatestudent E = new Graduatestudent (); A. printName(); E. printNameO; c) Which line in the above code would result in a ClassCastException d) Which line in the above code would generate a compile error. e) Please give the corrected version of the line that causes the compile error. ............. 1234 567 801

Jun 05, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here