<< Chapter < Page Chapter >> Page >
This module contains review questions and answers related to bounded type parameters in Java.

Revised: Wed May 11 18:05:10 CDT 2016

This page is included in the following Books:

Table of Contents

Preface

This module is one in a collection of modules on Java Generics designed for teaching ITSE2317 - Java Programming (Intermediate) at Austin Community College in Austin, TX.

This and future modules in this series will be based on the Generics (Updated) section of The Java Tutorials from Oracle. (In the event that these links become broken, you should have no difficulty finding the Oracle material with an online search.)

You will find the learning resources for this module on the Oracle site at:

This module contains review questions and answers keyed to the material in the above listed documents.

Once you study that material, you should be able to answer the review questions in this module.

Once you complete your study of all the material on generics , you should be able to answer the review questions at Questions and Exercises on the Oracle site.

The questions and the answers in this module are connected by hyperlinks tomake it easy for you to navigate from the question to the answer and back again.

Questions

Question 1 .

True or False: Bounded type parameters are used to restrict the types that can be used as arguments in a parameterized type.

Answer 1

Question 2

True or False: To declare a bounded type parameter, list the type parameter's name, followed by the extends or implements keyword, followed by its upper bound class or interface.

Answer 2

Question 3

True or False: A type parameter can have multiple bounds as shown in Figure 1 .

Figure 1 - Question 3.
<T extends B1&B2&B3>

Answer 3

Question 4

True or False: The code shown in Listing 1 will compile and run successfully producing the output shown in Figure 2 .

Listing 1 - Question 4.
/*File Q04.java ************************************************/import java.awt.*; /*Note the following inheritance hierarchyjava.lang.Object java.awt.Componentjava.awt.Container java.awt.Windowjava.awt.Frame */public class Q04{public static void main(String[] args){Foo<Window>aFoo = new Foo<>(); aFoo.runIt();}//end main }//end class Q04//=============================================// class Foo<T extends Frame>{ public void runIt(){System.out.println("Object instantiated."); }//end runIt}//end Foo
Figure 2 - Question 4.
Object instantiated.

Answer 4

Question 5

Define and write a class named A05Foo which, when combined with the code shown in Listing 2 will produce the output shown in Figure 3 .

Listing 2 - Question 5.
/*File Q05.java ************************************************/import java.awt.*; /*Note the following inheritance hierarchyjava.lang.Object java.awt.Componentjava.awt.Container java.awt.Windowjava.awt.Frame */public class Q05{public static void main(String[] args){A05Foo<Window>aA05Foo = new A05Foo<>(); aA05Foo.runIt();}//end main }//end class Q05//=============================================//

Questions & Answers

summarize halerambos & holbon
David Reply
the Three stages of Auguste Comte
Clementina Reply
what are agents of socialization
Antonio Reply
sociology of education
Nuhu Reply
definition of sociology of education
Nuhu
what is culture
Abdulrahim Reply
shared beliefs, values, and practices
AI-Robot
What are the two type of scientific method
ogunniran Reply
I'm willing to join you
Aceng Reply
what are the scientific method of sociology
Man
what is socialization
ogunniran Reply
the process wherein people come to understand societal norms and expectations, to accept society's beliefs, and to be aware of societal values
AI-Robot
scientific method in doing research
ogunniran
defimition of sickness in afica
Anita
Cosmology
ogunniran
Hmmm
ogunniran
list and explain the terms that found in society
REMMY Reply
list and explain the terms that found in society
Mukhtar
what are the agents of socialization
Antonio
Family Peer group Institution
Abdulwajud
I mean the definition
Antonio
ways of perceived deviance indifferent society
Naomi Reply
reasons of joining groups
SAM
to bring development to the nation at large
Hyellafiya
entails of consultative and consensus building from others
Gadama
World first Sociologist?
Abu
What is evolutionary model
Muhammad Reply
Evolution models refer to mathematical and computational representations of the processes involved in biological evolution. These models aim to simulate and understand how species change over time through mechanisms such as natural selection, genetic drift, and mutation. Evolutionary models can be u
faruk
what are the modern trends in religious behaviours
Selekeye Reply
what are social norms
Daniel Reply
shared standards of acceptable behavior by the group or appropriate behavior in a particular institution or those behaviors that are acceptable in a society
Lucius
that is how i understood it
Lucius
examples of societal norms
Diamond
Discuss the characteristics of the research located within positivist and the interpretivist paradigm
Tariro Reply
what is Industrialisation
Selekeye Reply
industrialization
Angelo
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Object-oriented programming (oop) with java. OpenStax CNX. Jun 29, 2016 Download for free at https://legacy.cnx.org/content/col11441/1.201
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Object-oriented programming (oop) with java' conversation and receive update notifications?

Ask