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

Write a java application that allows a user to enter

Write a Java application that allows a user to enter numbers into an array and then process them. Enter the number of elements and the value of each element; Your application will process the data entered and will displa ...

Javapizzacontactlistat the beginning of all your programs

JavaPizza ContactList At the beginning of all your programs, put a comment box that includes the program name, your name, and a brief description of the program. Example: /************************************************ ...

Problem specificationyou have been approached by a local

Problem Specification You have been approached by a local university for designing and implementing a room access control system on the university campus. Access to each room on each floor of each campus building is cont ...

Learning outcomes1use different program control statements

Learning Outcomes: 1. Use different program control statements in a programming language 2. Demonstrate the use of arrays with a programming language 3. Define and work with classes and objects in a programming language. ...

The requirement is to design a system using jsp in

The requirement is to design a system using jsp in netbeans. You need to add other functions such as search by text, advance search, quantity update by admin, quantity check at the checkout, login and registering page, a ...

Assignmentpersonasas has been outlined there are three

Assignment Personas As has been outlined there are three specific groups who would be considered the core demographic for the users of this site. Sue Smith Age: 35 years old Gender: Female Location: Vancouver, BC Educati ...

Assignmentthis assignment will give you a chance to

Assignment This assignment will give you a chance to exercise your knowledge of extending jQuery and of multimedia players like the JWPlayer. We're building on the "divide-text-into-spans" example we started in Homework ...

This assignment consists of two sectionsbulljava program

This assignment consists of two sections: • Java program file(s) • A screenshot of the execution and source code of your Java program Label each file name according to the section of the assignment for which it is writte ...

Module assignment introduction to programming using

Module Assignment: Introduction to Programming Using Java This assignment is to provide practice using arrays and strings along with other Java programming techniques discussed so far in the course. For this assignment, ...

Question adiscuss the good and the bad of javascript

Question A Discuss the good and the bad of JavaScript Libraries. In what circumstances would you use Libraries? 80 words max Prime Numbers Note: A prime number is a number that can only be divided by itself or by one. Wr ...

  • 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

WalMart Identification of theory and critical discussion

Drawing on the prescribed text and/or relevant academic literature, produce a paper which discusses the nature of group

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