Professional Documents
Culture Documents
1. Write a main method to input a length in meters using constructors, convert this to feet
and inches, and write both lengths on the screen. 1 meter = 39.4 inches.
2. A diamond merchant has recently received a consignment of stones. The diamonds are to
be categorized by weight according to Figure 5.20. At the end of the weighing, the
merchant requires a print-out of the total number of stones in each category and the
percentage weight of each category. Assume that the electronic scale the merchant uses is
calibrated in milligrams. Write a program to input the weights of the diamonds and
output the required statistics. Note: 200 mg is equivalent to 1 carat (SI).
3. Write a program to store the alphabet as characters in an array. The program should
display:
5. Write a Survey class that will support taking surveys on various topics. The class should make
use of the CheckBox class for a survey in which a particular question that will posed, along with
a list of potential answers. The class should allow the programmer to easily define, administer,
and report the results of the survey.
Next write a program that uses the Survey class to survey a group of students about why
they are studying computer programming and Java.
6. Sometimes, the class can contain only the method declaration, without and body. And these
classes can also be used to implement multiple inheritances. What are these classes and explain
the same with suitable example.
8. Sometimes we want a class to inherit from more than one class. In Java how it can be
accomplished? Explain it briefly and also write a program to implement it.