Day 3: Assignment OOP Part-2 Solved

49.99 $

Category: Tags: , , , , ,
Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: zip solution files instantly, after Payment

Securely Powered by: Secure Checkout

Description

5/5 - (3 votes)

Ques 1: Can we have a non-abstract method inside an interface?
Explain by writing the code snippets..!
//Write the code justifying the answer…
Ques 2: Implement 2 interfaces in a single class having same default methods and observe the catch there?
//Write the code implementing miultiple interfaces by a class //Multiple interfaces should have default methods with same signature
Ques 3: Observe the following code and answer
// Shape.java public class Shape { protected void display() { System.out.println(“Display-base”); } } // Circle.java public class Circle extends Shape { < < access – modifier > void display() { System.out.println(“Display-derived”); } }
Day 3: Assignment OOP Part-21 → Write which modifier can be used in above written code snippet..
a. Only protected can be used. B. public and protected both can be used. C. public, protected, and private can be used.
d. Only public can be used.
Ques 4: Observe and answer.. also try to run and play around the code
abstract class Car { static { System.out.print(“1”); }
public Car(String name) { super(); System.out.print(“2”); }
{ System.out.print(“3”); } }
public class BlueCar extends Car { { System.out.print(“4”); }
public BlueCar() { super(“blue”); System.out.print(“5”); }
public static void main(String[] gears) { new BlueCar(); } }
What will be the output of above code snippet?
Day 3: Assignment OOP Part-22 a. 23451 b. 12354 c. 13245 d. The code does not compile
Ques 5: Observe the following code snippet
class Math { public final double secret = 2; }
class ComplexMath extends Math { public final double secret = 4; }
public class InfiniteMath extends ComplexMath { public final double secret = 8;
public static void main(String[] numbers) { Math math = new InfiniteMath(); System.out.print(math.secret); } }
What will be the output of above code?
a. 2 b. 4 c. 8 d. The code does not compile.
Day 3: Assignment OOP Part-23

  • Day-3-vww7yu.zip