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

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

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