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 program non-gui preferred to demonstrate the

Write a Java program (non-GUI preferred) to demonstrate the use of an ArrayList. The program should allow a user to do the following: Add, edit, delete different types of animals Select an animal, and the corresponding c ...

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 ...

Program- java applet to practice multiplication with user

Program- Java Applet to Practice Multiplication with User Interaction 1) Develop a Java applet that will help an elementary school student learn multiplication. Use the Math.random method or a Random object to produce tw ...

Assignmentdevelop a cinema ticket booking application in

Assignment Develop a Cinema Ticket Booking Application in Java with the following functionality, available from the console: Requests the Customer's name, age and asks if they are a student Lists films that are currently ...

Java program 1write a java application that generates a

Java Program 1 Write a Java application that generates a 3-digit random number 100 times. Display the output for each of the generated numbers and the sum of all 100 numbers. Demonstrate your code compiles and runs witho ...

Java programmingscenario a mom and pop used car dealership

JAVA PROGRAMMING 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 2. Remove From Inven ...

Write a java program and pseudocode to read a number up to

Write a java program and pseudocode to read a number up to 15 digits long or a date (dd/mm/yyyy). The program should distinguish numbers from input date, and prints them in alphabetic spelling form. Example: for input 23 ...

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, ...

The taskyou must design and implement in java a bookshop

The Task You must design and implement in Java a Bookshop Management System corresponding to the attached scenario. You are not required to implement the entire scenario, but the more functionality your system has, the h ...

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 ...

  • 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