1) What is wrong in the following code? (Note that the compareTo method for the Integer and Double classes was introduce

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) What is wrong in the following code? (Note that the compareTo method for the Integer and Double classes was introduce

Post by answerhappygod »

1) What is wrong in the following code? (Note that the compareTomethod for the Integer and Double classes was introduced inprevious 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)));
}}
1 What Is Wrong In The Following Code Note That The Compareto Method For The Integer And Double Classes Was Introduce 1
1 What Is Wrong In The Following Code Note That The Compareto Method For The Integer And Double Classes Was Introduce 1 (26.46 KiB) Viewed 83 times
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;}}5) 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());
) - Which of the following is a correct interface? interface A { void print() { }; (a) abstract interface A { print (); } (c) abstract interface A extends 11, 12 [ abstract void print() { }; interface A { void print(); (b) (d)
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply