Ask Question, Ask an Expert

+1-415-315-9853

info@mywordsolution.com

Ask Java Expert


Home >> Java

Problem 1:

 class Shape {
 int noOfShape;
 Shape() //Constructor
 {
   System.out.println(“Shape constructor”);
 }
  Shape(int s) //Constructor
 {
    noOfShape = s;
 System.out.println(“Shape=“+noOfShape);
 }
}
class Rectangle extends Shape {
 int noOfRectangle;
  Rectangle()  // Constructor
 {
 super(99);
 System.out.println(“Rectangleconstructor”);
 }
 Rectangle(int r) //Constructor
 {
  noOfRectangle = r;
 System.out.println(“Rectangle =“+noOfRectangle);
 }
}
class Box extends Rectangle {
 int noOfBox;
  Box(int b)  // Constructor
 {
  noOfBox = b;
 System.out.println(“Box =“+noOfBox);
 }
}
class testMain {
  public static void main(String arg[])
 {
    Box b1 = new Box(10);
    Rectangle r1 = new Rectangle(20);
    Shape s1 = new Shape(30);
    Rectangle r2 = new Rectangle();
    Shape s2 = new Shape();
 }
 }

problems:

problem1. Define the term constructor. Using the above Java program describe constructor chaining.

problem2. describe the declaration: Rectangle r1 = new Rectangle (20).

problem3. What is the meaning of keywords super and extends?

problem4. What is the output of above Java program?

Java, Programming

  • Category:- Java
  • Reference No.:- M95566

Have any Question? 


Related Questions in Java

Assignmentbullusing html css and javascript design a

Assignment • Using HTML, CSS and JavaScript. Design a webpage with the following: • The design of all Web pages in the site must include: o a header at the top of the page, o a horizontal navigation bar below the header, ...

Jva programmingmodify the given java application attached

JAVA PROGRAMMING Modify the given Java application (attached) using NetBeans IDE to meet these additional and changed business requirements: • The application will now compare the total annual compensation of at least tw ...

Develop a console program for java on microsoft notepad

Develop a console program for JAVA on Microsoft notepad that simulates a section of a restaurant menu. Each item will have a different price and your program should define at least ten items. You will need to obtain an o ...

Create a separate class for the selected product that holds

Create a separate class for the selected product that holds the item number, the name of the product, the department in which the product belongs, the number of units in stock, and the price of each unit. You must use th ...

Program 1objectivethis program assignment is provided to

Program 1 Objective: This program assignment is provided to let the students know how to handle threads and enhance system availability on a multiprocessor or multicore environment. A single process is supposed to create ...

Java programthis assignment will count as both homework and

Java Program This assignment will count as both homework and lab. Develop a program that will allow the user to display the starting line and the bench for a basketball team. The user will also have the option of swappin ...

Modify the week two java application using netbeans ide to

Modify the Week Two Java application using NetBeans IDE to meet these additional and changed business requirements: The company has recently changed its total annual compensation policy to improve sales. A salesperson wi ...

Java programingproject requirementsscenario a mom and pop

java programing Project Requirements SCENARIO: A Mom and Pop used car dealership wants you to create a program that will manage their sales and inventory. They have provided a menu for you to follow. 1. Add To Inventory ...

The paris hotels company needs a computer program to track

The Paris Hotels Company needs a computer program to track their hotel occupancy for the hotels in their chain. Write a Java program that calculates the occupancy rate for each floor of a hotel. A hotel's occupancy rate ...

When programming or solving any sort of problem for that

When programming, or solving any sort of problem for that matter, abstraction plays a key role in the decision-making process. It allows you to remove irrelevant details in order to understand the bigger picture. For exa ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Section onea in an atwood machine suppose two objects of

SECTION ONE (a) In an Atwood Machine, suppose two objects of unequal mass are hung vertically over a frictionless

Part 1you work in hr for a company that operates a factory

Part 1: You work in HR for a company that operates a factory manufacturing fiberglass. There are several hundred empl

Details on advanced accounting paperthis paper is intended

DETAILS ON ADVANCED ACCOUNTING PAPER This paper is intended for students to apply the theoretical knowledge around ac

Create a provider database and related reports and queries

Create a provider database and related reports and queries to capture contact information for potential PC component pro

Describe what you learned about the impact of economic

Describe what you learned about the impact of economic, social, and demographic trends affecting the US labor environmen