Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java Generics in Java Generics in Java Generics Quiz

Why the answer is all of those?

Hi, i dont understand why the answer is all of theseto the question: Which of these objects can we pass in to the logPresentr method?

Is it because <P> extends Object?, like <T>? Tonnie Fanadez

2 Answers

Tonnie Fanadez
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Tonnie Fanadez
UX Design Techdegree Graduate 22,793 Points

Hi noob developer

It should be all of them.

Just remember in Java we can define our own classes type and give them whatever name we can think of. Sock is-a(n) Object because it extends/inherits from Object Class. Chocolate Class is-a Object. A collection of Amazon Gift Cards is also an Object since a Gift Card Type is-a child of the Object Super-class.

In short *All Java Class Types * inherit their properties from the Object Class.

In return Objects of the same type can be grouped together using Collections (*Lists, Sets, Maps or Queues *).

In Collection<T> T is just a placeholder and any child of Object Class can be inserted in between the diamond brackets.

Hi Tonnie Fanadez how are u? So am i right with my question or no?, <P> is like <T>, <P> its a placeholder and any child of Object?

btw How's the techdegree, what u learn there?

Tonnie Fanadez
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Tonnie Fanadez
UX Design Techdegree Graduate 22,793 Points

Hi noob developer

You're correct both <P> and <T> are the same, they are placeholders.

UX design is fantastic and it teaches how to be creative and lot of exposure across IT fields. I am liking it and will keep you posted.