Question
**JAVA **PLEASE INCLUDE THE **SCREENSHOT**OF THE RUNNING PROGRAM! PROGRAM: A) class Cycle{ private int numberOfWheels; private int weight; Cycle(int numberOfWheels,int weight){ this.numberOfWheels=numberOfWheels; this.weight=weight; } public
**JAVA **PLEASE INCLUDE THE **SCREENSHOT**OF THE RUNNING PROGRAM!
PROGRAM:
A)
class Cycle{ private int numberOfWheels; private int weight; Cycle(int numberOfWheels,int weight){ this.numberOfWheels=numberOfWheels; this.weight=weight; } public void print(){ System.out.println("Number Of wheels :"+numberOfWheels); System.out.println("Weight "+weight); } } public class CycleDriver{ public static void main(String args[]){ Cycle C1=new Cycle(2,10); C1.print(); } } OUTPUT:
B)
class Cycle{ private int numberOfWheels; private int weight; Cycle(){ this(100,1000); } Cycle(int numberOfWheels,int weight){ this.numberOfWheels=numberOfWheels; this.weight=weight; } public void print(){ System.out.println("Number Of wheels :"+numberOfWheels); System.out.println("Weight "+weight); } } public class CycleDriver2{ public static void main(String args[]){ Cycle C1=new Cycle(); C1.print(); } }
B programs javac cycle Driver -java B programs java Cycle Driver Number of wheels :2 height 10 B: programsStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started