1) write an abstract class a ball. You must include 2 variables common to all balls, and at least one abstract method. T

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

1) write an abstract class a ball. You must include 2 variables common to all balls, and at least one abstract method. T

Post by answerhappygod »

1) write an abstract class a ball. You must include 2 variablescommon to all balls, and at least one abstract method. Then, createtwo concrete subclasses of ball that define a specific type of balland override the abstract method.
2) 3) - Show the error in the following code:interface A {void m1();}class B implements A {void m1() {System.out.println("m1");}}4) - What is wrong in the following code?
public class Test {public static void main(String[] args) {Person[] persons = {new Person(3), new Person(4), newPerson(1)};java.util.Arrays.sort(persons);}}class Person {private int id;Person(int id) {this.id = id;}}
3) Show the output of the following code?Rational r1 = new Rational(-2, 6);System.out.println(r1.getNumerator());System.out.println(r1.getDenominator());System.out.println(r1.intValue());System.out.println(r1.doubleValue());
6) What is wrong in the following code? (Note that thecompareTo method for the Integer and Double classes was introducedin previous chapters)public class Test {public static void main(String[] args) {Number x = new Integer(3);System.out.println(x.intValue());System.out.println(x.compareTo(new Integer(4)));}}
7)
1 Write An Abstract Class A Ball You Must Include 2 Variables Common To All Balls And At Least One Abstract Method T 1
1 Write An Abstract Class A Ball You Must Include 2 Variables Common To All Balls And At Least One Abstract Method T 1 (46.66 KiB) Viewed 31 times
Which of the following is a correct interface? interface A { } void print() { }; abstract interface A { print(); } abstract interface A extends I1, I2 { abstract void print() { }; } interface A { void print(); } (b) (d)
5) - Show the output of following program: public class Test { public static void main(String[] args) { new A(); new B(); } } class A { int i = 7; public A() { setI (20); System.out.println("i from A is " + i); } public void setI (int i) {
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply