gs gs111 Types of Classes (Using Java) - Generic Class - Quiz No.1
gs gs111 OOP Object Oriented Programming Java Quiz
This quiz belongs to book/course code gs gs111 OOP Object Oriented Programming Java of gs organization. We have 178 quizzes available related to the book/course OOP Object Oriented Programming Java. This quiz has a total of 10 multiple choice questions (MCQs) to prepare and belongs to topic Types of Classes (Using Java). NVAEducation wants its users to help them learn in an easy way. For that purpose, you are free to prepare online MCQs and quizzes.
NVAEducation also facilitates users to contribute in online competitions with other students to make a challenging situation to learn in a creative way. You can create one to one, and group competition on an topic of a book/course code. Also on NVAEducation you can get certifications by passing the online quiz test.
class Generic<T> { T t; Generic(T t) { this.t = t; } public T getT() { return this.t; } } class MainCall { public static void main (String[] args) { Generic <Integer> i = new Generic<Integer>(25); System.out.println(i.getT()); Generic <Double> j = new Generic<Double>(37); System.out.println(j.getT()); } }
25 37
25 37.0
class Generic<T,U> { T t; U u; Generic(T t, U u) { this.t = t; this.u = u; } public void append() { System.out.print(u); System.out.print(t); } } class GenericString { public static void main (String[] args) { Generic <String, String> i = new Generic<String, String>("San", "foundry"); i.append(); } }
class Generic<T> { T t; Generic(T t) { this.t = t; } public T getT() { return this.t; } } class GenericString2 { public static void main (String[] args) { Generic <String> i = new Generic<String>("NVAEducation"); System.out.println(i.getClass()); System.out.println(i.getT().getClass()); } }
class T class Generic
class Generic class String
class Generic class java.lang.String
class T class java.lang.String
class Generic<T> { T t; Generic(T t) { this.t = t; } public T getT() { return this.t; } } class GenericInt { public static void main (String[] args) { Generic <Integer> i = new Generic<Integer>(100); Generic <Generic> j = new Generic<Generic>(i); System.out.println(j.getClass()); System.out.println(j.getT().getClass()); } }
class Generic class Integer
class Generic class java.io.Integer
class Generic class java.lang.Integer
class Generic class Generic
class Generic<T> { T t; Generic(T t) { this.t = t; } public T getT() { return this.t; } } class GenericProg { public static void main (String[] args) { Generic <String> i = new Generic<String>("NVAEducation"); System.out.println(i); } }
class Generic <T> { Stack <T> t = new Stack <T>(); public void push(T i) { t.push(i); } public T pop() { return t.pop(); } public Stack Array() { return t; } } public class GenericPop { public static void main(String args[]) { Generic <String> i = new Generic<String>(); i.push("San"); i.push("foundry"); System.out.println(i.Array()); System.out.println(i.pop()); System.out.println(i.pop()); } }
NVAEducation NVAEducation
[San, foundry] San foundry
[San, foundry] foundry San
class Generic <T> { Stack <T> t = new Stack <T>(); public void push(T i) { t.push(i); } public T pop() { return t.pop(); } } public class GenericStack { public static void main(String args[]) { Generic <String> i = new Generic<String>(); i.push("37"); i.push(37.0); System.out.println(i.pop()); System.out.println(i.pop()); } }
37 37.0
"37" 37.0