Why wont the following program compile correct it so that


1. Indicate whether each of the following statements is true or false:

An abstract class can have ordinary methods but an interface cannot.
An abstract class cannot have any constructors.
No class can implement more than one interface.
It is not possible to create an instance of an abstract class.
All methods of an interface are implicitly public.

2. Why won't the following program compile? Correct it so that it will compile and properly implement Comparable.

class Int implements Comparable
{
private int x;
public Int(int x)
{
this.x = x;
}
public int compareTo(Int other)
{
return x - other.x;
}
}

3. What is the output of the following program?

class A
{
public A()
{
System.out.println(
"The default constructor of A is invoked");
}
}

class B extends A
{
public B()
{
System.out.println(
"The default constructor of B is invoked");
}
}

public class C
{
public static void main(String[] args)
{
B b = new B();
}
}

4. Given the following class and interface definitions:

class Base
{
...
}

interface Spec
{
...
}

class Derived extends Base implements Spec
{
}

For each of the following declarations, indicate whether it is correct or incorrect and provide an explanation.
Derived object2 = new Base();
Spec object3 = new Derived();
Spec object4 = new Base();
Base object1 = new Derived();
Derived object5 = new Spec();

5. Indicate whether each of the following will compile and if not, correct it so it will.

class Class1
{
abstract void method1()
{
}
}

abstract class Class2
{
abstract void method2();
void method3();
}

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: Why wont the following program compile correct it so that
Reference No:- TGS01090641

Expected delivery within 24 Hours