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

  Write a statement to create a jframe object

Write a statement to create a JFrame object with a title of "My GUI Application" - Write a Java statement to have the object from the question above manage its display area by dividing it into 3 rows which have 4 columns each.

  Write a class called misc that has no instance variables

Write a static double method called evaluateQuadraticPolynomial that takes four double parametersa, b, c, and x and returns the value of ax^2 + bx + c

  Java code using jframe

Write a Java code using JFrame. This code needs to manipulate 4 shapes(2 rectangles and 2 squares) in a 400x400 JFrame. This needs to manipulate the shapes in 3 different ways, using 3 different methods. One for translating a shape, one for proportio..

  Write a test program that obtains from the user

Write a test program that obtains from the user the items to store in two sets A and B, and displays the union A u B, the inter- section A n B, and the dierence A \ B. The data type of the items is your choice. ( you can only store objects.)

  Write java program to print price of table-furniture company

Write down the Java program for furniture company. Ask user to select P for Pine, O for Oak or M for Mahogany. Illustrate the price of table produced with chosen wood.

  Create your listarray class

Create your ListArray class that is functionally similar to the formal Java ArrayList Utility class. here are the requirements

  Write and run a java program

Write and run a Java program which allows the user to input two doubles and outputs the greater of the two?

  Write an array where the user can input 7 temperatures

Write an array where the user can input 7 temperatures; include a 'for' loop. Make sure the temperatures are larger than -100 and smaller than or equal to 120, if not, make sure the user enters a valid number. Make sure the temperature is between the..

  Java programming murach 4th ed 1open the ch06ex1invoice

1.open the ch06ex1invoice project. take a screenshot after you open netbeans and paste it into a word or word

  Assume that you are developing a java program which uses

suppose that youre developing a java program that uses decimal numbers and youd like to control the formatting of your

  Java program to decide whether integer is perfect number

For example, 6 is a perfect number because 6 = 1 + 2 + 3. Write a Java program that decides whether integer is a perfect number.

  Implement/update specific methods for the dfs of a graph

implement/update specific methods for the DFS of a graph; for at least 2 graphs (1 being the provided one), show the DFS order of vertices in the graph, and for each node,

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