Sie sind auf Seite 1von 1

06-06994/21699 Software Workshop

Spring Semester 2012-13


Tutorial 07/02/2013
The University of Birmingham
School of Computer Science
Apostolos Giannakidis


!"#" %&''()*+&,- ",. /(,(0+)-
!"#"$%&' !"#$%&$'&$( *+#, -./+/ -/ 0/*% #**1
!" What uo the teims formal type parameter (oi type parameter),
actual type parameter (oi type argument), parameterized type,
generic type anu generic type invocation mean.
#" Can a piimitive type be useu as a type argument.
a. What uoes the teim boxed primitive type mean?
b. What is autoboxing anu unboxing.
)*%&+ $"&,- ./ '.0" 112 &.#&"-3'
$" What is polymorphism?
a. What is polymorphism by inheritance.
b. What is polymorphism by interfaces.
%" What is method overriding.
a. Bow can }ava annotations help in methou oveiiiuing.
&" What is method overloading.
!"#"$%&'4 5.66"&3%.#'4 7#3"$/,&"' ,#8 2.690.$-:%'0
'" Suppose you have a supei class vehicle with 1 abstiact methou
getNum0fWheels(). Then, suppose you have the subclasses of vehicle, Cai anu
Notoicycle, that implement the abstiact methou.
Examine the following coue:
List<Vehicle> myList = new ArrayList<Vehicle>();
myList.add( new Car() );
myList.add( new Motorcycle() );
for (Vehicle s : myList)
System.out.println( s.getNumOfWheels() );
In the above coue, iuentify:
a) the Inteiface that was useu
b) the Collection implementation
c) the ueneiic type aigument
u) how is Polymoiphism achieveu
e) what is the output, assuming that the constiuctois of the subclasses set the
numbei of wheels of the object.
(" If we ueciue to change the Collection to a LinkeuList, what changes aie neeueu.
)" If we want to change it to a Set.
;.$3%#< &.66"&3%.#'= 5.0-,$,>6" ,#8 5.0-,$,3.$
*" What is the uiffeience between java.util.Collection anu
java.util.Collections.
!+" What uoes natural order mean.
!!" In oiuei to use Collections.sort() in a List of objects of a custom class,
how shoulu the custom class be implementeu.
!#" Bow can we soit a Collection of objects baseu on uiffeient fielus.
5:"&+ &.66"&3%.#' /.$ 8*-6%&,3"'= "?*,6'@A ,#8 :,':5.8"@A
!$" What is the methou signatuie of equals(). Why is it impoitant.
!%" What is the contiact when oveiiiuing equals().
!&" What is the contiact between equals() anu hashCode().

Das könnte Ihnen auch gefallen