128k views
2 votes
Some classes, like the ArrayList class, use angle brackets in their documentation and their declaration. For example, the Java documentation for the ArrayList class starts with this: public class ArrayList. What is the name for classes that have extra "parameter(s)" in angle brackets like this? Group of answer choices generic classes specific classes hard classes type classes

1 Answer

3 votes

Answer:

The answer to the following question is Generic classes.

Explanation:

The declaration of the generic classes is the same as the declaration of non-generic classes but except the class name has followed by the type of parameter section.

The parameter section of the generic class can have only one or more than one type parameter which is separated by the commas.

Following example can explain that how can define generic class.

public class demo<D> {

private D d;

public void fun(D d) {

this.d = d;

}

public D get() {

return d;

}

public static void main(String[] args) {

demo<Integer> integerdemo = new demo<Integer>();

demo<String> stringdemo = new demo<String>();

integerdemo.fun(new Integer(10));

stringdemo.fun(new String("Hello World"));

System.out.printf("The Integer Value is :%d\\\\", integerdemo.get());

System.out.printf("The String Value is :%s\\", stringdemo.get());

}

}

User Eternal Noob
by
5.5k points