Assignment Questions Due Date - 17-10-2021
Assignment Questions Due Date - 17-10-2021
1. Write a function that takes two String arguments, and uses all the Boolean
comparisons to compare the two Strings and print the results. For the == and
!=, also perform the equals( ) test. In main( ), call your function with some
different String objects.
2. Create a switch statement that prints a message for each case, and put the
switch inside a for loop that tries each case. Put a break after each case and
test it, then remove the breaks and see what happens.
3. Create a class called Dog with an overloaded bark( ) method. This method
should be overloaded based on various primitive data types, and print different
types of barking, howling, etc., depending on which overloaded version is
called. Write a main() that calls all the different versions.
4. Create a class called Tank that can be filled and emptied, and has a death
condition that it must be empty when the object is cleaned up. Write a finalize(
) that verifies this death condition. In main (), test the possible scenarios that
can occur when your
Tank is used.
5. Create an inheritance hierarchy of Rodent: Mouse, Gerbil, Hamster, etc. In
the base class, provide methods that are common to all Rodents, and override
these in the derived classes to perform different behaviors depending on the
specific type of Rodent. Create an array of Rodent, fill it with different specific
types of Rodents, and call your base-class methods to see what happens.
6. Create three interfaces, each with two methods. Inherit a new interface from
the three, adding a new method. Create a class by implementing the new
interface and also inheriting from a concrete class. Now write four methods,
each of which takes one of the four interfaces as an argument. In main( ),
create an object of your class and pass it to each of the methods.