Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

True or False Questions: Please answer the following questions either "true" or "false If, our answer is false, correct the statement so that it is true.

1. A class is a container for holding static member variables and methods. A class is also used like a blueprint to construct objects.

2. While there may be many objects constructed from a class, there can be only one of each type of class.

3. A variable can hold only a reference to an object. By reference, we mean the memory address where the object is located.

4. A constructor cannot have the same name as the class in which it is defined.

5. The word create is used to construct objects, as in the following example:

ClassType myObject = create ClassType();

6. A constructor has a return type.

7. Many constructors can be defined for the same class, as long as their signatures are different from one another.

8. It is legal to use a non-static member variable in a static method, but it is not legal to use a static member variable in a non-static method.

9. An object knows to which class it actually belongs because information about the actual class of the object is stored as part of the object's construction.

10. The word extends is used to create subclasses.

11. A class can have many immediate/direct superclasses.

12. A variable that can hold a reference to an object from class A can also hold a reference to an object from any subclass of class A.

Questions 13 through 23 relate to the class defined in Problem 13.

13. A tournament organizing company wants to automate parts of its database. As part of its software, a Tournaments class has been created. For the following class definition, indicate which member variables and methods belong to the class and which belong to objects constructed from the class.

class Tournaments (
private static int numBasketball; private static int numVollcyball; public String eventNamc;
public int numGames;
public String monthHcld;
// constructors would go here
public static int getNumBasketballa {
return numBasketball;
}
public static int getNumVollcyball() ) { return numVolleyball; 'a
public String idLevel0fPlay () {
String x null;
return x;
}
}

14. Suppose that a subclass of Tournaments is defined.

a. Can it include additional member variables that are not included in the superclass Tournaments?

b. Can it exclude any of the member variables that are included in Tournaments?

c. Can it include additional member methods that are not included in Tournaments?

d. Can it modify any of the member methods that are included in Tournaments%

15. Write the definition for a default constructor for the class Tournaments. The constructor should initialize the variable eventName to "Mid-West Regional Basketball", numGames to 15, and monthHeld to "March", respectively. Include means for updating any state variables that need to be updated.

16. Write the definition for a constructor for the class Tournaments, whereby the variables eventName and numGames are initialized according two parameters, eventName and numGames, respectively. Again, include menus for updating any stale variables that need to be updated. To do so, use a third parameter to distinguish whether an event is basketball or volleyball, so Maybe state variables are correctly updated.

17. What is the value to which monthlield is initialized in (16) above?

18. Call the default constructor in Problem 15 to construct a type Tournaments object called event 1.

19. Call the constructor with parameters in Problem 16 to construct a type
Tournaments object called event2. The event name should be "State H.S. Women's Volleyball", and the number of games (matches in this case) should be 31.

20. Construct an array of type Tournaments objects. The array should have 4 elements. Use the default constructor.

21. Define a subclass of Tournaments called CollegeGames. The subclass should include an additional member having type String and visibility public. The name of the member variable will be "sponsor". Modify idLevel0fPlay so that the second line in the method reads as follows:
Sting x "CollegeGames";

22. Suppose that another subclass of Tournaments is called HighSchoolGames. Suppose that a type CollegeGames object and a type HighSchoolGames object have been constructed. If the first object is called collegel and the second object is called
hsl, construct an array that can hold both of these objects. Store the objects in the array, using a means that you have learned.

23. Using array notation, how would you print the name of the subclass from which each element in the array arose'?

24. What will the following print?

Int[] myArray an new int[3];
for (int i = 0; i < myArray.length; ++i) { myArray[i] = i +3;
int x = 5;
myFunction (myArray, x );
System.outprintin (myArray[1]);
System.out.println (x);
myFunction ( myArray, x );
System.out.println(myArray[1])
System.out.println(x);
if myFunction is defined to be as follows?
public static void myFunction(inta al, int xi) ( a1[1]+= 1;
xl += 2;
}

25. List all the different ways that you can extract information from a function. One is print statements to standard out (your monitor) or a file. There are at least three others.

Java, Programming

  • Category:- Java
  • Reference No.:- M91766085

Have any Question?


Related Questions in Java

Operating systems assignment -problem 1 sharing the bridgea

Operating Systems Assignment - Problem 1: Sharing the Bridge A new single lane bridge is constructed to connect the North Island of New Zealand to the South Island of New Zealand. Farmers from each island use the bridge ...

Object-oriented software development1 introduction 11

OBJECT-ORIENTED SOFTWARE DEVELOPMENT 1. Introduction 1.1 Assignment Requirement 1.2 Deliverables and Structure (what to submit) 1.3 Software Restrictions 1.4 How to score high... 1.5 Assumptions 2. System Requirements 2. ...

Assessment -java program using array of Assessment -JAVA Program using array of objects

Assessment -JAVA Program using array of objects Objectives This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details For this assignment, you are required to develop a Windowed G ...

Applied software engineering assignment 1 -learning

Applied Software Engineering Assignment 1 - Learning outcomes - 1. Understand the notion of software engineering and why it is important. 2. Analyse the risk factors associated with phases of the software development lif ...

Assessment instructionsin this assessment you will design

Assessment Instructions In this assessment, you will design and code a simple Java application that defines a class, instantiate the class into a number of objects, and prints out the attributes of these objects in a spe ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Can someone please help me with the following java

can someone please help me with the following java question The input is an N by N matrix of nonnegative integers. Each individual row is a decreasing sequence from left to right. Each individual column is a decreasing s ...

Retail price calculatorwrite a java program that asks the

Retail Price Calculator Write a JAVA program that asks the user to enter an item's wholesale cost and its markup percentage. It should then display the item's retail price. For example: (If an item's wholesale cost is 5. ...

Assignment - java program using array of objectsobjectives

Assignment - JAVA Program using array of objects Objectives - This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details - For this assignment, you are required to develop a Menu ...

Solving 2nd degree equationsbull write the following java

Solving 2nd degree equations • Write the following Java methods • boolean real-sols(double a, double b, double c): it returns true if the 2nd degree equation ax2 + bx + c has real solutions • double solution1(double a, d ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As