Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

4. Given class Bulb App.java below. Write a program that can do the following: a. Create an object bl of type Bulb b. Set watt

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
4. Given class Bulb App.java below. Write a program that can do the following: a. Create an object bl of type Bulb b. Set watt with 12 and color with white" c. Show the output of bl on screen. Write your code on the sheet provided. Write your code BulbApp.java here. 3. Create a class Bulb with two attributes watt of type integer and color of type String. Include set and get method for all attributes. Bulb watt: int + set Watt(int) void + getColor(int Write your code Bulb.java here. 2. Given class DollApp.java below. Type and find the output. Write your answer the sheet provided import java.util.Scanner; public class DollApp { public static void main() Scanner in - new Scanner(System.in); System.out.println("Creating a doll.."); Doll dolli = new Doll(); doll1.pressMe(); doll1.setName("Rita"); dolli.pressMe(); System.out.print("Would you like to set name?Y/N:>"); char choice = in.next().charAt(@); in.nextLine(); if((choice - 'Y')||(choice 'y')) System.out.print("Enter the name: "); String name-in.nextLine(); dolli.setName(name); > doll1.pressMe(); 3 Output: Objective(s): The objective of this Lab Tutorial exercise is to familiarize with simple object definition with input-output statements, assignments, and control statements of JAVA programming language. Learning Outcome(s): Upon completion of this laboratory exercise, the student able to: 1. Write a complete and executable JAVA programs following object-oriented approach. 2. Write a class declaration following a sample given. Instruction(s): 1. Create a class Doll with one attribute name of type String. Include set and get method for attribute name. Doll name: String + setName(String):void + getName():String +pressMe():void Sample Code: public class Doll { private String name; public Doll() { name= ""; } public Doll(String n) { setName(n); } public void setName(String n) {name = n;} public void pressMe() { System.out.println("Hi I am " + name);} }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Experts Guide To SQL

Authors: Frank Lusardi

1st Edition

0070390029, 978-0070390027

More Books

Students also viewed these Databases questions

Question

4. Does cultural aptitude impact ones emotional intelligence?

Answered: 1 week ago

Question

7. Do the organizations social activities reflect diversity?

Answered: 1 week ago