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

Chatbotscreate a small networked chat application that is

Chatbots Create a small, networked chat application that is populated by bots. Introduction On an old server park, filled with applications from the early days of the internet, a few servers still run one of the earliest ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

Assignment game prototypeoverviewfor this assessment task

Assignment: Game Prototype Overview For this assessment task you are expected to construct a prototype level/area as a "proof of concept" for the game that you have designed in Assignment 1. The prototype should function ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

In relation to javaa what is constructor the purpose of

(In relation to Java) A. What is constructor? the purpose of default constructor? B. How do you get a copy of the object but not the reference of the object? C. What are static variables and instance variables? D. Compar ...

Project descriptionwrite a java program to traverse a

Project Description: Write a java program to traverse a directory structure (DirWalker.java) of csv files that contain csv files with customer info. A simple sample in provided in with the sample code but you MUST will r ...

Fundamentals of operating systems and java

Fundamentals of Operating Systems and Java Programming Purpose of the assessment (with ULO Mapping) This assignment assesses the following Unit Learning Outcomes; students should be able to demonstrate their achievements ...

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 ...

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. ...

  • 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