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

Create a class named BankAccount, containing: a constructor accepting a String corresponding to the name of...
Create a class named BankAccount, containing: a constructor accepting a String corresponding to the name of the account holder. a method, getBalance, that returns a double corresponding to the account balance. a method withdraw that accepts a double, and deducts the amount from the account balance. Write a class definition for a subclass, CheckingAccount, that contains: a boolean instance variable, overdraft. (Having overdraft for a checking account allows one to write checks larger than the current balance). a constructor that...
you will find a class called Employee. This class should include a constructor that sets name...
you will find a class called Employee. This class should include a constructor that 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 create a...
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...
Write a Java class. The class name must be ShapeMetrics, which means the file name must...
Write a Java class. The class name must be ShapeMetrics, which means the file name must be ShapeMetrics.java. Provide the following functions: 1. getAreaOfRectangle(), with two float arguments, width and height, in that order, returning a float value which is the area of the rectangle with that width and height. 2. getSpaceDiagonalOfRectangularCuboid (), with three float arguments, width, height, and depth, in that order, returning a float value which is the length of the diagonal line which bisects the cuboid....
Write a class GBP2HKD containing the following methods: (a) constructor : which builds the frame shown...
Write a class GBP2HKD containing the following methods: (a) constructor : which builds the frame shown on the right side. The frame consists of • a pull-down menu "Action" with menu items "Convert" and "Exit", • a textfield to enter GBP amount. Some text is in the text field to provide information to the user on what to input. The user needs to delete the text before entering the numbers. • a label to display the amount of HKD (please...
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
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...
This is for Javascript programming language: A. Class and Constructor Creation Book Class Create a constructor...
This is for Javascript programming language: A. Class and Constructor Creation Book Class Create a constructor function or ES6 class for a Book object. The Book object should store the following data in attributes: title and author. Library Class Create a constructor function or ES6 class for a Library object that will be used with the Book class. The Library object should be able to internally keep an array of Book objects. B. Methods to add Library Class The class...
Homework Assignment 4 Instructions: Class name must be: HW4_yourName For example: Michael will name the class...
Homework Assignment 4 Instructions: Class name must be: HW4_yourName For example: Michael will name the class of homework assignment 4 as HW4_Michael Grading Rubric: Code running and as per the required conditions and giving expected output = 10 points File named as per instructions = 1 point Comments in code = 4 points Problem: Average calculation for a list Write a program that reads a text file named test_scores.txt to read the name of the student and his/her scores for...
The GroceryItem class must maintain the name of the item and its price (a double). You...
The GroceryItem class must maintain the name of the item and its price (a double). You must read the grocery data from file, and store each line's information in a single GroceryItem object. In other words, there should be one GroceryItem object created for each line in the file. Implement all standard and necessary getters and setters, as well as constructors. Also, implement a calculateWithTax method that takes a double parameter, and returns the price with the tax added. The...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT