MCQOPTIONS
Bookmark
Saved Bookmarks
→
Java Programming
→
Exceptions
→
Which two classes use the Shape class correctly?..
1.
Which two classes use the Shape class correctly?
A.
C,E
B.
T,H
C.
A,C
D.
B,E
E.
None of these
Answer» E. None of these
Show Answer
Discussion
No Comment Found
Post Comment
Related MCQs
What is the outcome of below code box class?<br><pre class="prettyprint lang-c">class Shape <br>{<br> public int area()<br> {<br> return 0;<br> }<br>}<br><br>class Square extends Shape <br>{<br> public int area()<br> {<br> return 5;<br> }<br>}<br><br>class Rectangle extends Shape <br>{<br> public int area()<br> {<br> return 9;<br> }<br>}<br><br>public class box<br>{<br> public static void main(String[] args)<br> {<br> Shape obj = new Square();<br> Shape obj0 = new Rectangle();<br> obj = obj0;<br> System.out.println(obj.area());<br> }<br>}<br></pre>
What is the outcome of below code Box class?<br><pre class="prettyprint lang-c">class Shape <br>{<br> public int area()<br> {<br> return 1;<br> }<br>}<br><br>class Square extends Shape <br>{<br> public int area()<br> {<br> return 2;<br> }<br>}<br><br>class Rectangle extends Shape <br>{<br> public int area()<br> {<br> return 3;<br> }<br>}<br><br>public class Box<br>{<br> public static void main(String[] args)<br> {<br> Shape obj = new Shape();<br> Square obj0 = new Square();<br> Rectangle obj1 = new Rectangle();<br> obj1 = (Rectangle)obj0;<br> System.out.println(obj0.area());<br> }<br>}<br></pre>
What is the outcome of below code Output class?<br><pre class="prettyprint lang-c">class Shape <br>{<br> public int area()<br> {<br> return 2;<br> }<br>}<br><br>class Square extends Shape <br>{<br> public int area()<br> {<br> return 5;<br> }<br>}<br><br>class Rectangle extends Shape <br>{<br> public int area()<br> {<br> return 7;<br> }<br>}<br><br>public class Output<br>{<br> public static void main(String[] args)<br> {<br> Shape obj = new Shape();<br> Square obj0 = new Square();<br> Rectangle obj1 = new Rectangle();<br> obj1 = (Rectangle)obj;<br> System.out.println(obj0.area());<br> }<br>}<br></pre>
What is the outcome of below code SquareExample class?<br><pre class="prettyprint lang-c">class Shape <br>{<br> public int area()<br> {<br> return 2;<br> }<br>}<br><br>class Square extends Shape <br>{<br> public int area()<br> {<br> return 7;<br> }<br>}<br><br>public class SquareExample<br>{<br> public static void main(String[] args)<br> {<br> Shape obj = new Shape();<br> Square obj0 = new Square();<br> obj0 = obj;<br> System.out.println(obj0.area());<br> }<br>}<br></pre>
What is the outcome of below code Rectangle_Example class?<br><pre class="prettyprint lang-c">class Shape <br>{<br> public int area()<br> {<br> return 2;<br> }<br>}<br><br>class Rectangle extends Shape <br>{<br> public int area()<br> {<br> return 6;<br> }<br>}<br><br>public class Rectangle_Example<br>{<br> public static void main(String[] args)<br> {<br> Shape obj = new Shape();<br> Rectangle obj0 = new Rectangle();<br> obj = obj0;<br> System.out.println(obj.area());<br> }<br>}<br></pre>
Which two classes use the Shape class correctly?<br><pre class="prettyprint lang-c"><br>A. public class Circle implements Shape <br> {<br> private int radius;<br> }<br><br>B. public abstract class Circle extends Shape <br> {<br> private int radius;<br> }<br><br>C. public class Circle extends Shape <br> {<br> private int radius;<br> public void draw();<br> }<br><br>D. public abstract class Circle implements Shape <br> {<br> private int radius;<br> public void draw();<br> }<br><br>E. public class Circle extends Shape <br> {<br> private int radius;<br> public void draw()<br> {<br> /* code here */<br> }<br> }<br><br>F. public abstract class Circle implements Shape <br> {<br> private int radius;<br> public void draw() <br> { <br> /* code here */ <br> }<br> }<br></pre>
What is the output of this program?<br><pre class="prettyprint lang-c"><br>class N <br> {<br> int K;<br> } <br> class M extends N<br> {<br> int L;<br> void display() <br> {<br> super.K = L + 5;<br> System.out.println(K + " " + L);<br> }<br> } <br> public class inheritance_Example<br> {<br> public static void main(String args[])<br> {<br> M object = new M();<br> object.K=4;<br> object.L=3; <br> object.display(); <br> }<br> }<br></pre>
What is the output of this program?<br><pre class="prettyprint lang-c"><br>class N <br> {<br> public int K;<br> public int L;<br> N() <br> {<br> K = 5;<br> L = 2;<br> }<br> } <br> class M extends N<br> {<br> int p;<br> M() <br> {<br> super();<br> } <br> } <br> public class inheritance_super_use <br> {<br> public static void main(String args[])<br> {<br> M obj = new M();<br> System.out.println(obj.K + " " + obj.L); <br> }<br> }<br></pre>
What is the output of this program?<br><pre class="prettyprint lang-c"><br>class N <br> {<br> int K;<br> void display() <br> {<br> System.out.println(K);<br> }<br> } <br> class M extends N<br> {<br> int L;<br> void display() <br> {<br> System.out.println(L);<br> }<br> } <br> public class inheritance_Example<br> {<br> public static void main(String args[])<br> {<br> M object = new M();<br> object.K=5;<br> object.L=6; <br> object.display(); <br> }<br> }<br></pre>
What is the outcome of below Square_Shape_Example class?<br><pre class="prettyprint lang-c">class Shape <br>{<br> public int area()<br> {<br> return 1;<br> }<br>}<br><br>class Square extends Shape <br>{<br> public int area()<br> {<br> return 5;<br> }<br>}<br><br>public class Square_Shape_Example<br>{<br> public static void main(String[] args)<br> {<br> Shape obj = new Shape();<br> Square square = new Square();<br> obj = square;<br> System.out.println(obj.area());<br> }<br>}<br></pre>
Reply to Comment
×
Name
*
Email
*
Comment
*
Submit Reply