Question

In: Computer Science

1. From the constructor, you infer that the name of the class containing the constructor must be_______ .


1. From the constructor, you infer that the name of the class containing the constructor must be_______ .

2. Fill in the blanks so that the statement will instantiate a JButton object and assigns it to variable of JButton type:

JButton btn= _______ ("OK");

3. Fill in the blanks to complete the description of the constructor in the corresponding UML class diagram:

+<>______( _____ : ______)

Solutions

Expert Solution

1. From the constructor, you infer that the name of the class containing the constructor must be_______ .

Ans: JButton

Explanation: Class name and Method name will be same in case of constructor's


________________________________________________________________________________________________________________

2. Fill in the blanks so that the statement will instantiate a JButton object and assigns it to variable of JButton type:
JButton btn= _______ ("OK");

Ans: JButton btn= new JButton("OK");

Explanation: Instantiate the class JButton by passing string "OK" that will create a button with label "OK"

________________________________________________________________________________________________________________

3. Fill in the blanks to complete the description of the constructor in the corresponding UML class diagram:
+<>______( _____ : ______)

Ans: +<>JButton( text : String )

Explanation: Method name is prefixed with <> word and parameters are enclosed in braces with parameter name first and then corresponding datatype.


Related Solutions

JavaScript - Create a class using "names" as the identifier. Create a constructor. The constructor must...
JavaScript - Create a class using "names" as the identifier. Create a constructor. The constructor must have elements as follow: first ( value passed will be String ) last ( value passed will be String ) age ( value passed will be Numeric ) The constructor will assign the values for the three elements and should use the "this" keyword Create a function, using "printObject" as the identifier printObject: This function will have three input parameters: allNames , sortType, message...
JAVA The class will have a constructor BMI(String name, double height, double weight). The class should...
JAVA The class will have a constructor BMI(String name, double height, double weight). The class should have a public instance method, getBMI() that returns a double reflecting the person's BMI (Body Mass Index = weight (kg) / height2 (m2) ). The class should have a public toString() method that returns a String like Fred is 1.9m tall and is 87.0Kg and has a BMI of 24.099722991689752Kg/m^2 (just print the doubles without special formatting). Implement this class (if you wish you...
To infer an outcome from a sample to the population, what assumption must be met for...
To infer an outcome from a sample to the population, what assumption must be met for all parametric statistics? A) Population is normally distributed B) Sample is small C) Population is small D) Population is large
Class Exercise: Constructor using JAVA Let’s define a Class together and have a constructor while at...
Class Exercise: Constructor using JAVA Let’s define a Class together and have a constructor while at it. - What should the Class object represent? (What is the “real life object” to represent)? - What properties should it have? (let’s hold off on the methods/actions for now – unless necessary for the constructor) - What should happen when a new instance of the Class is created? - Question: What are you allowed to do in the constructor? - Let’s test this...
In Angel, you will find a class called Employee. This class should include a constructor which...
In Angel, you will find a class called Employee. This class should include a constructor which sets name to blanks and salary to $0.00 and a constructor which sets name to a starting name and salary to a set amount. Additionally, the class should include methods to set the name and salary and return the name and salary. Create another method to return the name and salary nicely formatted as a string (hint – research the toString method). You will...
In Angel, you will find a class called Employee. This class should include a constructor which...
In Angel, you will find a class called Employee. This class should include a constructor which sets name to blanks and salary to $0.00 and a constructor which sets name to a starting name and salary to a set amount. Additionally, the class should include methods to set the name and salary and return the name and salary. Create another method to return the name and salary nicely formatted as a string (hint – research the toString method). You will...
C++ constructor initializer list Constructor initializer list:         - syntax         - when it must be...
C++ constructor initializer list Constructor initializer list:         - syntax         - when it must be used         - how to instantiate and initialize data members that are user-defined types at the same time
2. Program containing two modules: a. Create a class Code one programmer-written constructor Create several instance...
2. Program containing two modules: a. Create a class Code one programmer-written constructor Create several instance data attributes Create 3 methods which will each be invoked from the driver program - one method will not receive any parameters, but will return a value to driver program - one method will receive one parameter, and will also return a value to driver program - a display method will receive 2 parameters from driver program Define a constant properly; use the constant...
A constructor, with a String parameter representing the name of the item.
USE JAVA Item classA constructor, with a String parameter representing the name of the item.A name() method and a toString() method, both of which are identical and which return the name of the item.BadAmountException ClassIt must be a RuntimeException. A RuntimeException is a subclass of Exception which has the special property that we wouldn't need to declare it if we need to use it.Inventory classA constructor which takes a String parameter indicating the item type, an int parameter indicating the initial...
The Person Class Uses encapsulation Attributes private String name private Address address Constructors one constructor with...
The Person Class Uses encapsulation Attributes private String name private Address address Constructors one constructor with no input parameters since it doesn't receive any input values, you need to use the default values below: name - "John Doe" address - use the default constructor of Address one constructor with all (two) parameters one input parameter for each attribute Methods public String toString() returns this object as a String, i.e., make each attribute a String, concatenate all strings and return as...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT