MCQOPTIONS
Bookmark
Saved Bookmarks
→
Java Programming
→
Exceptions
→
What is the outcome of below code Output class?
1.
What is the outcome of below code Output class?
A.
Compilation Error
B.
Runtime Error
C.
Default value
D.
7
E.
5
Answer» C. Default value
Show Answer
Discussion
No Comment Found
Post Comment
Related MCQs
What is the outcome of below code box class?class Shape { public int area() { return 0; }}class Square extends Shape { public int area() { return 5; }}class Rectangle extends Shape { public int area() { return 9; }}public class box{ public static void main(String[] args) { Shape obj = new Square(); Shape obj0 = new Rectangle(); obj = obj0; System.out.println(obj.area()); }}
What is the outcome of below code Box class?class Shape { public int area() { return 1; }}class Square extends Shape { public int area() { return 2; }}class Rectangle extends Shape { public int area() { return 3; }}public class Box{ public static void main(String[] args) { Shape obj = new Shape(); Square obj0 = new Square(); Rectangle obj1 = new Rectangle(); obj1 = (Rectangle)obj0; System.out.println(obj0.area()); }}
What is the outcome of below code Output class?class Shape { public int area() { return 2; }}class Square extends Shape { public int area() { return 5; }}class Rectangle extends Shape { public int area() { return 7; }}public class Output{ public static void main(String[] args) { Shape obj = new Shape(); Square obj0 = new Square(); Rectangle obj1 = new Rectangle(); obj1 = (Rectangle)obj; System.out.println(obj0.area()); }}
What is the outcome of below code SquareExample class?class Shape { public int area() { return 2; }}class Square extends Shape { public int area() { return 7; }}public class SquareExample{ public static void main(String[] args) { Shape obj = new Shape(); Square obj0 = new Square(); obj0 = obj; System.out.println(obj0.area()); }}
What is the outcome of below code Rectangle_Example class?class Shape { public int area() { return 2; }}class Rectangle extends Shape { public int area() { return 6; }}public class Rectangle_Example{ public static void main(String[] args) { Shape obj = new Shape(); Rectangle obj0 = new Rectangle(); obj = obj0; System.out.println(obj.area()); }}
Which two classes use the Shape class correctly?A. public class Circle implements Shape { private int radius; }B. public abstract class Circle extends Shape { private int radius; }C. public class Circle extends Shape { private int radius; public void draw(); }D. public abstract class Circle implements Shape { private int radius; public void draw(); }E. public class Circle extends Shape { private int radius; public void draw() { /* code here */ } }F. public abstract class Circle implements Shape { private int radius; public void draw() { /* code here */ } }
What is the output of this program?class N { int K; } class M extends N { int L; void display() { super.K = L + 5; System.out.println(K + " " + L); } } public class inheritance_Example { public static void main(String args[]) { M object = new M(); object.K=4; object.L=3; object.display(); } }
What is the output of this program?class N { public int K; public int L; N() { K = 5; L = 2; } } class M extends N { int p; M() { super(); } } public class inheritance_super_use { public static void main(String args[]) { M obj = new M(); System.out.println(obj.K + " " + obj.L); } }
What is the output of this program?class N { int K; void display() { System.out.println(K); } } class M extends N { int L; void display() { System.out.println(L); } } public class inheritance_Example { public static void main(String args[]) { M object = new M(); object.K=5; object.L=6; object.display(); } }
What is the outcome of below Square_Shape_Example class?class Shape { public int area() { return 1; }}class Square extends Shape { public int area() { return 5; }}public class Square_Shape_Example{ public static void main(String[] args) { Shape obj = new Shape(); Square square = new Square(); obj = square; System.out.println(obj.area()); }}
Reply to Comment
×
Name
*
Email
*
Comment
*
Submit Reply
Your experience on this site will be improved by allowing cookies. Read
Cookie Policy
Reject
Allow cookies