Why wont the following given program compile

Assignment Help JAVA Programming
Reference no: EM13810417

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();
}

Reference no: EM13810417

Questions Cloud

What weapons are prohibited now? : What weapons are prohibited now
What will the holder receive when the bond matures : What will the holder receive when the bond matures? If the current rate of interest on a comparable debt is 8 percent, what should be the price of this bond? Would you expect the firm to call this bond Why?
Example of a performance measure : What does the phrase you get what you measure refer to? Give an example of a performance measure you’ve come across in your experience (work, school, or home) and comment on the strengths and weaknesses of that measure.
Discuss the issue of american military forces : Discuss the issue of how American military forces should be employed in conflict abroad
Why wont the following given program compile : Why won't the following program compile? Correct it so that it will compile and properly implement Comparable
Critical risk assessment and milestones schedule : Based on the organization you selected (Nationstar Mortgage Company), write a critical risk assessment and milestones schedule of 350-500 words (plus a spreadsheet) that addresses the following (guidelines):
Expected the inflation rate to average length of mortgage : Assume you are a banker and want a 4% real rate of return on your loans. if you expect that the inflation rate will average about 6% over the next thirty years, what rate should you charge your customers for a thirty year fixed rate mortgage? How wou..
Interactions in a presentation for senior leaders : Research and address the elements of organizational effectiveness that will improve interactions in a presentation for senior leaders:
Why would patricks actions be considered fraudulent : Patrick works for McGill’s Computer Repair, owned and operated by Frank McGill. As a computer technician, Patrick has grown accustomed to friends and family members asking for assistance with their personal computers. Why would Patrick’s actions be c..

Reviews

Write a Review

JAVA Programming Questions & Answers

  Run the code

Run the following code, Explain the output aYer you let it run 20 seconds, 5 minutes, 10 minutes.

  Create java application to create and maintain contact list

Create a JAVA application to create and maintain a contact list - Create a database to store the contact information.

  Write a recursive method that converts a decimal integer

Write a recursive method that converts a decimal integer to a binary swing. Write a recursive method that converts a binary string to a decimal integer.

  Create a class that implements movieloader

Fill in the empty Frame class that has been provided. Each object of this type will store data consisting of a single frame from an input le.

  What is an example of a javascript framework in the

what is an example of a javascript framework? in the framework you have described what is an example of an application

  In this project you need to write a program called

in this project you need to write a program called ecc.javato implement elliptic curve

  Methods are commonly used to break a problem down into

methods are commonly used to break a problem down into small manageable pieces. a large task can be broken down into

  Create a sales tracking program named salestracking.java

create a sales tracking program named SalesTracking.java. This program must track monthly sales as well as compute average yearly sales, total sales for the year, and which month had the highest sales and which month had the lowest sales.

  What is an abstract class and how does it differ from the

question 1 what is an abstract class and how does it differ from a regular class? question 2 why are abstract class

  Modify the inventory program by preparing a subclass of the

modify the inventory program by creating a subclass of the product class that uses one additional unique feature of the

  Write a java program that finds the temperature

Write a JAVA program that finds the temperature that is the same in both Celsius and Fahrenheit.

  A jsp expression can contain any java expression

A JSP expression can contain any Java expression that evaluates to a

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd