Java Quiz 20 A+ Questions and Answers

If you want to make a component opaque or transparent, what method do you use?
A) setOpaque
B) opaque
C) transparent
D) SetTransparent
2.
To access the number of columns in row i of a two-dimensional array named grades, we use _________________.
A) grades.length
B) grades( i ).length
C) grades( i ).size
D) grades{ i }.length
E) grades[ i ].length
3.
When class B inherits from class A?
A) A is the subclass and B is the superclass
B) A is the superclass and B is the subclass
4.
To access the number of rows in a two-dimensional array named grades, we use _________________.
A) grades.size( )
B) grades
C) grades.length( )
D) grades.size
E) rades.length
5.
The header of a method that potentially generates an exception when called contains the keyword _______________ .
A) generates
B) excepts
C) throws
6.
When creating a GUI application class, which class do we typically extend?
A) Container
B) Component
C) JFrame
D) Window
7.
Assuming the class B inherits from class A and method foo belongs to class A, what do we mean by overriding method foo in class B?
A) We are coding another version of method foo in class B
B) We are calling method foo in class B
C) We are not using method foo in class B
8.
Typically, _________________.
A) Recursion uses selection and iteration uses looping
B) Recursion uses looping and iteration uses selection
9.
Binary search applies to ________________.
A) Either an unsorted or a sorted array
B) An unsorted array
C) A sorted array
10.
What method is used to set the width and height of a window?
A) setSize
B) setHeightWidth
C) setWindow
D) setWidthHeight
11.
What keyword do we use in the class header that inherits from another class?
A) modifies
B) extends
C) protected
D) inherits
12.
What is the function of a GUI component?
A) Display information only
B) All of the above
C) Enable user interaction only
13.
If you want to disable a component, what method do you use?
A) Enabled
B) setEnabled
C) Disabled
D) SetDisabled
14.
Assuming the class B inherits from class A, then
A) An object of class B is an object of class A
B) All of the above
C) None of the above
D) An object of class A is an object of class B
15.
What Java keyword do we use in the constructor of a class inheriting from another class if we want to call the constructor of the inherited class?
A) clone
B) call
C) super
D) constructor
16.
To access the element at row i and column j of a two-dimensional array named grades, we use _________________.
A) grades( i )( j )
B) grades[ i ][ j ]
C) grades[ j ][ i ]
D) grades( j )( i )
E) grades
17.
A linked list ________________.
A) Can grow and shrink as items are added or deleted
B) Can shrink but not grow, i.e., items can be deleted but not added
C) Has fixed size
D) Can grow but not shrink, i.e., items can be added but not deleted
18.
Which package does the JFrame class belong to?
A) javax,swing
B) java.swing
C) java.awt
D) javax.awt
19.
Constructors
A) Are not inherited and cannot be accessed
B) Are accessible but are not inherited
C) Are inherited and can be accessed
D) Are inherited but cannot be accessed
20.
In order to handle an exception, we use a _________________ construct.
A) try and finally
B) try and catch
C) catch and finally

Download All 20 Answers : Click HERE

CMIS102 homework assignment 4

Problem definition: Write a pseudocode, using functions, that calculates the area and perimeter of a rectangle whose dimensions (length and width) are provided by a user.

A.    Problem Analysis – Following the directions in the assignment, clearly write up your problem analysis in this section.

B.     Program Design – Following the directions in the assignment, clearly write up your problem design in this section and comment your pseudocode.

C.    Test Data – Following the directions in the assignment, include your test data and expected results in this section.

Table 1. Include your test data table here
-----------------------------------------------------------

Create a class Rectangle with attributes length and width, each of which defaults to 1

(Rectangle Class) Create a class Rectangle with attributes length and width, each of which defaults to 1. Provide methods that calculate the rectangle's perimeter and area. It has set and get methods for both length and width. The set methods should verify that length and width are each floating-point numbers larger than 0.0 and less than 20.0. Write a program to test class Rectangle.

Download .zip file with Rectangle.java and Rectangletest.java : Click HERE

Draw the UML diagram for the class and then implement the class

Draw the UML diagram for the class and then implement the class. Write a program that creates two rectangles objects, one with width 4 and height 40 and the other with width 3.5 and height 35.9. Display the width, height, area, and perimeter of each rectangle in this order.

Download .java files : click HERE


CISP 1610 - Programming in C++ Midterm Examination

CISP 1610 - Programming in C++
Midterm Examination

You are to write a C++ program to compute federal personal income taxes.  The tax owned depends on how much money one makes as well as their filing status.  For our purposes we will use four filing statuses.  These are (1)single filers, (2)married filing jointly, (3)married filing separately, and (4)head of household. 

Tax Rate
Single Filers
Married Filing Jointly
Married Filing Separately
Head of Household
10%
Up to $7,550
Up to $15,100
Up to $7,550
Up to $10,750
15%
$7,551-$30,650
$15,101-$61,300
$7,551-$30,650
$10,751-$41,050
25%
$30,651-$74,200
$61,301-$123,700
$30,651-$61,850
$41,051-$106,000
28%
$74,201-$154,800
$123,701-$188,450
$61,851-$94,225
$106,001-$171,650
33%
$154,801-$336,550
$188,451-$336,550
$94,226-$168,275
$171,651-$336,550
35%
$336,551 or more
$336,551 or more
$168,276 or more
$336,551 or more

For each filing status there are six tax rates.  Each rate is applied to a given amount of the taxable income.  For example, for a taxable income of $450,000 for a single filer, $7,550 is taxed at 10%, ($30,650-$7,550) at 15%, ($74,200-$30,650) at 25%, ($154,800-$74,200) at 28%, ($336,550-$154,800) at 33%, and ($450,000-336,550) at 35%.


Variables
Name
Type
Description and edit specifications
statusCode
int
Status code must be from 1 to 4.  1=single, 2=married filing jointly, 3=married filing separately, 4= head of household, 9 = end processing.
taxableIncome
float
Taxable income is entered by the user from the keyboard.  The amount must be numeric and not less than $500.
taxAmt
float
taxAmt is a calculated field and is determined from the supplied tax table as applied to the taxableIncome. 

Your program should be modular, that is small blocks of code.  (Later in the semester when we encounter functions, you will see how handy modular development can be.)  You are to follow these specifications as closely as possible.  You should have code blocks that do the following:
  1. Input status code.  You should use a do/while loop to control the input logic.  You are to keep the user in the loop until the input is correct.  You are to ensure that the status codes are as specified above.
  2.  Input taxable income.  As in step 1, you are to use a do/while loop for this logic.  You are to keep the user in the loop until the input is valid.
  3. Calculate the tax owned as a result of status code and taxable income.  You are to use a switch statement for the appropriate logic for each status code.  You should manually calculate several cases to ensure your program is performing correctly.
  4. Display the results of the calculation step.  You are to output the status code, the string description of the status code, the taxable income, and the total tax amount.  You are to use appropriate formatting of the output.
  5. You main loop should be a while loop that repeat steps 1 through 4 until the user enters a status code of 9 that will terminate the job.


Hint:  As you can see the tax rates are the same for each of the filing statuses.  The primary differences in all the status groups are the range amounts for the applicable tax rates.

Example of calculations and resulting output (note: it is ok to take some liberties with the output format.)

Taxable Income:  $70000, Filing status of Married Filing Jointly
Taxable income brackets
Tax rate
Tax amt.
15100
.10
1510.00
(61300 – 15100)
.15
6930.00
(70000 – 61300)
.25
2175.00
Total Taxes

10615.00

Display of above
Filing status:  Married Filing Jointly
Taxable income:    $70000.00

Tax amount:          $10615.00

TYPE SOME PART OF QUESTION YOU ARE LOOKING FOR

.

.
acc week