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

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

Create a console based non-gui java program using netbeans

Create a console based, non-GUI Java program using NetBeans Integrated Development Environment (IDE) that displays "Hello world!" Take a screenshot that shows the program's successful compilation and execution. Submit bo ...

Write a java program that prints asks the user to enter a

Write a Java program that prints asks the user to enter a positive value (1 less than or equal to 200) and print each number up to that line, 1 per line with the following changes (SNAP CRACKLE POP). • If a number is *** ...

Introduction to programmingjava programming assignment

Introduction to Programming Java Programming Assignment: Objects and Loops Your previous Alice programs implemented the count (for) and while loops. This assignment will apply the same concepts to Java, along with a thir ...

Write a java program non-gui preferred to demonstrate the

Write a Java program (non-GUI preferred) to demonstrate the use of Iterator. The program should allow a user to do the following: Allow the reading of a collection of animal objects from an external file. Output on scree ...

Spell checker in python and javawrite a python code and

Spell checker in python and java Write a python code and java code that can take a whole sentence and do text analysis by checking the spelling mistakes and show the correct spelling. Example: Input: I have a peen. Outpu ...

Assignment introduction to programming using java1 write a

Assignment: Introduction to Programming Using Java 1. Write a program that uses one of the Map classes to implement a contact list. Contact information should include first name, last name, a phone number and an email ad ...

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

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

Question awhy is it important to avoid the use of reserved

Question A Why is it important to avoid the use of reserved words as you define variables, functions, methods, or identifiers? Do you have any get-arounds to the use of these reserved words that you like to use? (max 80 ...

  • 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