Mid Term Question 223
Mid Term Question 223
Any examinee found adopting unfair means will be expelled from the trimester / program as per UIU
disciplinary rules.
2. A Class named Movie containing following elements: name (String), origin (String), genre (String) and rating
(Float). Among them, name cannot be accessed outside the class and origin can only be accessed in inherited class. 6
Other two elements can be accessed from anywhere.
Write down the Movie Class which will contain following members:
a. Provide appropriate Access Modifier to the elements.
b. Create Necessary Methods to access name and origin from outside the class.
c. Two Parameterized Constructors where First Constructor will take all four elements and Second
Constructor will take only name and genre.
d. A method named void Details() that will print the details of the Movie in following format:
You are watching SHUTTER ISLAND
Origin: USA
Genre: Thriller
Rating: 8.2
3. package transport;
6
package publicTransport;
Bus(int licenseNo){
super.noOfWheels = 4;
this.licenseNo = licenseNo;
}
}
4 All of you know that FIFA 2022 with Brazil, Argentina controversy is a trendy topic. Given the 6
following UML diagram, which has three classes: Fifa, BrazilFans, and ArgentinaFans. Although each
detail is depicted in the UML diagram, some of the more complex parts are written here for convenience.
Fifa() constructor prints " Who will be winner?" message. The first line of the Fifa(int,String)
constructor body is called Fifa() constructor with the help of this keyword, and the remaining two lines
instantiate variables using this keyword. toString() methods return a string with the given format.
BrazilFans is a derived class of Fifa, which has a constructor with three parameters, the first two of
which are passed to the base class, and the last one is used to instantiate variables using this keyword.
toString() methods return a string with the given format. The incrementWorldCups() methods increase
the value of havingWorldCups by 1 when it is invoked.
ArgentinaFans is a derived class of Fifa, which has a constructor with three parameters, the first two of
which are passed to the base class, and the last one is used to instantiate variables using this keyword.
toString() methods return a string with the given format. The incrementWorldCups() methods increase
the value of havingWorldCups by 1 when it is invoked.
Mid is another class that contains main() methods. In the main() method, after creating objects of
ArgentinaFans and BrazilFans, if the noOfGoals of Argentina is greater than Brazil, then the
incrementWorldCups() method of ArgentinaFans is called; otherwise, the incrementWorldCups()
method of BrazilFans is called. Write the whole program appropriately so that when it executes, you get
the following output:
5 6