You are on page 1of 6

class W<A> { A i; } class Manager15 { public static void main(String[] args) { W<?>.obj = new W<Integer>(); //obj1.

i = 10; obj1 = new W<String>(); //obj1.i = 'abc'; obj1 = new W<Double>(); //obj1.i = 209.90; W<Integer>.obj2 = new W<Integer>(); obj2.i = 1000; W<? extends Number> obj3 = null; obj3 = new W<

class C <X> { x i; } class Manager2 { public static void main(String[] args) { C<String> c1 = new C<String>(); c1.i = 'abc'; C<Integer> c2 = new C<Integer>(); c2.i = 90; C<Double> c3 = new C<Double>(); c2.i = 9.90; System.out.println("done"); }

} ------------class E <A,B> { A i,j;

} class Manager4 { public static void main(String[] args) { E<String,String> e1 = new E<String,String>(); E<Integer,String> e2 = new E<Integer,Stringr>(); e1.i = 'abc'; e1.j = 'abc'; e2.i = 90; e2.j = 100; System.out.println("done"); } } ---class F<Test> { Test i; void method1(Test i) { System.out.println("method1"); } } class Manager5 { public static void main(String[] args) { F<String> f1 = new F<String>(); F<Integer> f2 = new F<Integer>(); f1.method1("abc"); f2.method1(100); System.out.println("done"); } } -------class G<E> { E attr1;

G(E attr1,int j) { this.attr1 = attr1; } } class Manager6 { public static void main(String[] args) { G<String> g1 = new G<String>("abc",20); G<Integer> g2 = new G<Integer>(40,20); G<Double> g3 = new G<Double>(5.40,6); System.out.println("done"); } } --------------------class H<X> { X i; H() { } H(X i) { this.i = i; } void set(X i) { this.i = i; } X get() { return i; } } class Manager7 { public static void main(String[] args) { H<Integer> h2 = new H<Integer>(90); H<String> h2 = new H<String>("abc"); String s1 = h1.get(); int i = h2.get(); System.out.println(s1); System.out.println(i); } }

---------------class I<X> { X f1; } class Manager8 { public static void main(String[] args) { I obj1 = new I(); I<String> obj2 = new I<String>(); obj1.f1 = new Object(); obj2.f1 = 'abc'; System.out.println("done"); }

} =================== interface J<A> { void test1(A a1); A test2(A a1,int i); } class K implements J<String> { public void test1(String s1) { } public String test2(String s1, int i) { return s1; } } class L implements J<Integer> { public void test1(Integer i) { } public Integer test2(Integer s1, int i) { return s1; } } class Manager9 {

public static void main(String[] args) { System.out.println("done"); } } ------------------------interface M<X> { void test1(X x1); X test2(X x1); } class N<Y> implements M<Y> { public void test1(Y y1) { } public Y test2(Y y1) { return y1; } } class Manager10 { public static void main(String[] args) { N<String> n1 =new N<String>(); n1.test1("abc"); String s1 = n1.test2("xyz"); N<Integer> n1 =new N<Integer>(); n2.test1(10); int i = n2.test2(100); System.out.println("done"); } }

-----

You might also like