O slideshow foi denunciado.
Utilizamos seu perfil e dados de atividades no LinkedIn para personalizar e exibir anúncios mais relevantes. Altere suas preferências de anúncios quando desejar.

Online Java Tutorial - Java Practice Tests

Learn Java even if you don't know C/C++. Practice with 600 Java Programs and 2000 MCQs to perfect your learning.

  • Entre para ver os comentários

  • Seja a primeira pessoa a gostar disto

Online Java Tutorial - Java Practice Tests

  1. 1. 3 > If you are the first personto give the Correct Answerand Explanation, then you are eligible fora mobile recharge‘ The amount of recharge is linked to the numberof friends and followers we have. It can vary from Rs. 40 to Rs. 100. More Details at http: //java. meritcampus. com/ dailydose Request: Please reviewthe previous comments before postingyouranswer. Post onlyif you think none of the previous comments are correct. Note: The processing of the recharge can take up to 7 days. public static void main(String[] args) 4: new C() . create(), - new D() . update(), - new R() . read(): new D() . de1ete(), - lclass C ( 3 ) public void create () ( System. out. print("c"): } class U ( private void update() { ) System. out. print("u")- ) iclass R extends C ( public void create() protected void read() } ( System. out. print("C" } ( System. out. print("R"): l class D extends U { void update () void delete () ( System . out . print (' { System. out. print ( "D Daily Dose O61 12-Feb-2013 CURD CURD CURD Compilation Error
  2. 2. Ifyou are the first person to give the Correct Answerand Explanation, then you are . I eligible fora mobile recharge. The amount of recharge is linked to the number of Dal Y Dose friends and followers we have. It can varyfrom Rs.40 to Rs. 100. 0 6 2 More Details at http: //java. meritcampus. com/ dailydose _ ‘ Request: Please reviewthe previous comments before posting youranswer. Post m e only if you think none ofthe previous comments are correct. Note: The processingofthe recharge can take up to 7 days. 13-Feb-2013 What will be the output of the following program? ‘ Eclass B { static int i; static int j: static { i = 15: j = i — 5; l public static void main(String[] args) { int i = 0: A a = null, for (; i < 3; i++) ( a : new A(); a. i : B. i,' B. i += a. add(a. operate(i)): l System. out. println(B. i + “ ” + B. j + ” ” + i + ” ” + a. i); 5 l : l Eclass A { int i = 0: int operate(int i) ( if (B. j - i = = i ‘ i ' i) return -i; return i * i: 1 int addlint i) ( return this. i + i: } if. 14 1o 3 0 [El 14 10 3 16 l? 120 10 3 61 Some other output not shown here i E Compilation Error
  3. 3. If you are the first personto give the Correct Answerand Explanation, then you are D . | D eligiblefora mobile recharge. The amount of recharge is Iinkedto the numberof 3' V ose friends and followers we have. It can vary from Rs. 40 to Rs. 100. 0 6 3 More Details at http: //lava. meritcampus. com/ dailydose Request: Please review the previous comments before posting your answer. Post only if you think none ofthe previous comments are correct. Note: The processing of the recharge can take upto 7 days. If expections Alix and mix are defined as shown below, which of the methods in the Exceptions'I'est class fail to compile? , . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. , Eclass AEX extends Exception (} iclass Bflx extends ABx H iclass P. xceptions'l‘est ( void m1() { try [ throw]-t(fa1se), ' throwB(true), ' ) catch (BBx aex) ( l I void m2() ( try ( throwA(true); th. rowB(fa1se); } catch (AB: bex) ( ) i void m3() throws Afix ( tr)’ 1 throw? -(fa1se) ; throwB(true) ; } catch (BE: bex) ( throw bex; l l void m4() throws BBx ( try ( throwA(true) ; throwB(fa1se) ; 1 catch (AB: aex) ( throw aex; l l void throwA(boo1ean throwflx) throws Alix ( if (throwfix) throw new AEx() ; l void throwB(boo1ean throwfix) throws BBX l if (throwlix) throw new BE. x();
  4. 4. Ifyou are the first person to give the Correct Answerand Explanation, then you are . eligible fora mobile recharge. The amount of recharge is linked to the number of Dany Dose friends and followers we have. It can varyfrom Rs.40 to Rs. 100. O More Details at http: //java. meritcampus. com/ dailydose . ‘ Request: Please reviewthe previous comments before postingyouranswer. Post m e| "|‘| _' only if you think none ofthe previous comments are correct. Note: The processingofthe recharge can take up to 7 days. 15-Feb-2013 Given that the exceptions AEx, BEX and CEX are defined as shown below, which of the methods in , ' Runt1meExcept1ons fails to compile. “ r - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "1 Eclass AEx extends RuntimeException () 1 Eclass BEx extends Exception (} 3 iclass CEx extends AEx () . class Runtimelilxceptions ( . void m1() throws Alix, BEx, CEx ( ) void m2 () throws Exception ( throwB(true) ; throwAC(fa1se) ; } void n13 () ( throwAC(false) ; ) void m4 () throws AEx, BEx ( throwAC(true) ; } L 1 void m5 (boolean value) ( 1 “Y i throwB(value) , ' l catch (Exception ex) ( 1 } finally ( throw}-lcifalse) , - 1 ) 1 ) . void throwB(boolean value) throws CEX, BEX ( if (lvalue) throw new BEx() : l void throwAC(boolean value) ( if (! value) throw new AEx() ; 1 throw new CEx() ; 1 Al m1, m5 m1, m2, m3, m4, m5 £1 m2, m4, m5 m3, m5 l E 1 All of them compile with out any errors
  5. 5. Ifyou are the first person to give the Correct Answerand Explanation, then you are . eligible fora mobile recharge. The amount of recharge is Iinkedto the numberof Dafly Dose friends and followers we have. It can varyfrom Rs.40 to Rs. 100. O More Details at http: //java. meritcampusroni/ dailydose _ Request: Please reviewthe previous comments before postingyouranswer. Post onlyif you think none ofthe previous comments are correct. Note: The processing ofthe recharge can take upto 7 days. 16-Feb-2013 Given the classes M, N and 0, which of the classes U, W, X, Y and Z fail to compile. " -‘i iclass M l public void m1(int i) ( } ) éclass N { private void m1(int i, int j) l ) ) iclass 0 { protected void m1(int i) l ) ) §/ / ------------ —- iclass U extends O ( private void mllint i, int j) { ) ) iclass W extends 1-! ( protected void in1(int i, int j) ( 1 ) éclass 1’. extends 1-I { private void mllint i) ( ) ) Eclass Y extends N { private void mllint i) ( ) ) iclass 2 extends 0 { void m1(int k) ( ) ) K M, x, Y 13) u, x, Y, z E x, z E U, w, x E All of them compile
  6. 6. If you are the first person to give the Correct Answerand Explanation, then you are eligible fora mobile recharge. The amount of recharge is linked to the numberof Daily Dose friends and followers we have. It can vary from Rs. 40 to Rs. 100. 0 6 6 More Details at http: //java. meritcampus. com/ dailydose Request: Please reviewthe previous comments before posting your answer. Post only if you think none of the previous comments are correct. Note: The processing of the recharge can take upto 7 days. what will be the output of the following program? ipublic class Delta l static boolean Oka(char c) l Systein. out. print(c + " "); return true, ‘ l public static void mai. n(Strin9l] argv) ( inti=0: for (Oka('A'); (i < 2) G6 0ka('B'); Oka('C')) l i++; °k3('D'). ' ABDCBDCB E] ABCDBCD
  7. 7. If you are the first person to give the Correct Answerand Explanation, then you are eligiblefora mobile recharge. The amount of recharge is Iinkedto the numberof friends and followers we have. It can varyfrom Rs.4o to Rs. 100. More Details at http: //java. meritcampus. com/ dailydose Request: Please review the previous comments before posting your answer. Post onlyif you think none ofthe previous comments are correct. Note: The prooessingofthe recharge can take upto 7 days. Daily Dose O67 18-Feb-2013 What will be the output of the following program? class Colnpareobjects ( public static void main(String[] args) ( l A a - new A(); A a2 = new A(), - a2.i = 68; B b = new B(); B b2 = new B(); b2.i - 40; b2.j - 28; print(a 2 a2) ; pri. nt(b = a2), - print(b. equa1s (a2)); print(a2 -= b2); print(a2.equa1s (b2)); print(b -2 b2); print (b. equa1s (b2)); a2.iH-, - print (b. equa1s (a2)); public static void print(boo1ean value) ( l '1 : class A( Syste| n.out. print(va1ue ? "'l' " : "F "); int i = 45; int sum() ( return i; 1 public boolean equals (Object obj) ( l - l Eclass B extends A ( return sum() = = ((11) obj). sum(); int j - 23; int: sun() (return i + j; } FFTFTFTT [E Some ol: her output not shown here
  8. 8. If you are the first person to give the Correct Answerand Explanation, then you are . I eligible fora mobile recharge. The amount of recharge is linked to the numberof Dal Y Dose friends and followerswe have. It can vary from Rs.40 to Rs. 100. More Details at http: //lava. meritcampus. com/ dailydose Request: Please reviewthe previous comments before postingyour answer. Post only if you think none of the previous comments are correct. Note: The prooessingof the recharge can take upto 7 days. What will be the output of the following program? lclass Interfaces ( public static void liai. n(String[] args) ( I i - new I() ( public void print(char c, int i) ( Pr'mt(e) ; print((char) i); ) void print(cbar c) ( System. out. print(c + " "), ' ) l: i. print('A' , 67) ; i - new I() ( public void pr'1nt(char c, int i) ( print(c) ; prinui); l void print(int i) ( Systan. out. print(i + " "); ) l; i. print('C' , 72); l interface I ( void print(char c, int i); ) E 65 67 67 72 3 Compilation Error
  9. 9. If you are the first person to give the correct Answerand Explanation, then you are eligible for a mobile recharge. The amount of recharge is linked to the numberof Daily Dose friends and followe rs we have. Itcan varyfrom Rs. 40 to Rs. 100. 0 More Details at http: //java. me ritcampus. com/ dailydose Request: Please reviewthe previous comments before posting youranswer. Post onlyif you think none of the previous comments are correct. 2o'Feb'2013 Note: The processing of the recharge can take upto 7 days. What will the output of the following program? ‘class Str1ngTest ( public static void main(Strin9[l args) ( String a = "A"; String b - "B"; String ab = a + b; string :11 - new String("A"); String a2 = new String(a); System. out. print(ab. equals(a + b) ? ": " : "; "), ' System. out. print(ab as a + b ? "(" : "-"); SysteIn. out. print(a. equals(a1) ? ")" : "D"); System. out. print(a = - a1 ? ": " : "; "); System. out. print(a2 = a1 ? "-" : "! "); . print(a = - b ? "P" : "D");
  10. 10. If you are the first person to give the Correct Answerand Explanation, then you are D . l D eligible fora mobile recharge. The amount of recharge is linked to the numberof 3' V 056 friends and followers we have. It can vary from Rs. 40 to Rs. 100. 0 More Details at http: //java. me ritcampus. com/ dailydose Request: Please reviewthe previous comments before postingyouranswer. Post only if you think none of the previous comments are correct. Note: The prooessingof the recharge can take upto 7 days. What will be the output of the following program? class Stringsearcb ( public static void main(String[] args) l String s = "Banana Panama Vikrana Akron Dwakra"; print (s . indexOf("na")) ; print (s. i.ndex0f("na" , s. i. ndexOf("na") )); print (s . lastIndex0f("na")) ; print (s . lastIndex0f("alu: ")) ; print. (s . 1astIndex0f("alLr" , s . 1astIndexOf("nkr") ) ) ; System. out . print1n(s . substri. ng(s . indexof ( "ik") -1 , s . lastIndex0f("wa" ) —s . index0f("Pann" ) -1)); l private static void print(int value) ( Systan. out. print (value + "~") , ' 2~4~9~30~30~Vil<rama E] 2~2~9~30~2Z~ikrama
  11. 11. If you are the first person to give the Correct Answerand Explanation, then you are . I eligible fora mobile recharge. The amount of recharge is linked to the number of Dal V Dose friends and followers we have. It can vary from Rs. 40 to Rs. 100. 0 7 1 More Details at http: //java. me ritcampus. com/ dailydose Request: Please reviewthe previous comments before postingyouranswer. Post onlyif you think none of the previous comments are correct. 22'Feb'2013 Note: The prooessingof the recharge can take upto 7 days. what will be the output of the following program? . l public static void mai. n(Strinqll args) ( String s - "In£inity2K13"; StringBuffer sb = new StringBuffer(s), ' for (int i = CI; i < s.1engtb(); i++) l char current - s. charAt(i); s . replace (current , Character . toUpperCase (current) ) , ' l sb. rep1ace(9, 10, " 20"); Systein. out. println(s. split('2') [0] + sb. substring(9));
  12. 12. Ifyou are the first person to give the Correct Answerand Explanation, thenyou are . eligible fora mobile recharge. The amount of recharge is linked to the numberof Dallv Dose friends andfollowers we have. It can varyfrom Rs.40 to Rs. 100. 0 7 2 More Details at http: //java. meritcaInpus. conI/ dailydose ‘ _ Request: Please reviewthe previous comments before postingyouranswer. Post onlyif you think none of the previous comments are correct. Note: The processingofthe recharge can take up to 7 days. 23-Feb-2013 What will be the output of the following program? '1 lpublic class ThreadTest I 3 public static void mainlstringll args) '1 Bomb bl : new Bomb("Bomb 111. 2500), » Bomb b2 : new Bomb("Bomb 2 1000): Bomb b3 : new Bombl"Bomb 3 S00) 7 b1.start(): b2.run(), ' new Thread (b3) . startl) 7 I ) lclass Bomb extends Thread implements Runnable I 3 String name: int time'l'olIlail: : public Bomblstring name, int time'l'oWait) 1 this. name = name; this. time'l'oWait : t"uneToWait: ) public void run() try ( Thread. sleep(time'l'olrlait): i catch (Exception e) I I System. out. println(na. I.ne + 11 exploded“)? Bomb 2 exploded lil Bomb 3 exploded Bomb 1 exploded 7 Bomb 1 exploded l l Bomb 2 exploded Bomb 3 exploded 7 Bomb 3 exploded Bomb 2 exploded Bomb 1 exploded l Compilation Error l Runtime Error or goes Into infinite loop
  13. 13. If you are the first person to give the Correct Answerand Explanation, then you are . | eligible fora mobile recharge. The amount of recharge is linked to the numberof Dal V Dose friends and followers we have. It can varyfrom Rs. 40 to Rs. 100. 0 7 3 More Details at http: //lava. meritcampus. conI/ dailydose _ Request: Please review the previous comments before posting your answer. Post only if you think none ofthe previous comments are correct. Note: The processingofthe recharge can take upto 7 days. 24-Feb-2013 What will be the output of the following program? " class Arrayoutput : ( l public static void main(string s[]) l int a[] = (12, 15, 16, 17,19); for(int 1 : 5:1 > 0;‘1——) l 1 System . out . println (a [i] ) : 19 17 l A, 16 15 12 17 16 15 12 19 l C 15 12 lgl Compilation Error l E 1 Throws ArraylndexoutOfBound5Exception
  14. 14. If you are the first person to give the correct Answerand Explanation, then you are . I eligible fora mobile recharge. The amountof recharge is linked to the numberof Da' V Dose friends and followerswe have. Itcan varyfrom Rs. 40 to Rs. 100. O 7 4 More Details at http: //java. meritcampus. com/ dailydose Request: Please reviewthe previous comments before posting your answer. Post only if you think none ofthe previous comments are correct. 25'Feb'2013 Note: The processing of the recharge can take up to 7 days. In which order should the lines A, B, C, D be arranged such that it gets the required output? ll‘ Required output Ia = 4 b = 8 c = -5 . ‘I class Order1.ines ( public static void Inain(String[] args) I a=27 I 4+ 9; 13:52 / 6 - 3; cs3; a-H»-b; // LINBA a"b; // LINEB —b+a, ' / / LINBC (a<c) ? a%c: c%a; //LINED syst: an. out; .pri. nt1n("a- " + a+ " ha " +b+ " cs " + c);
  15. 15. Ifyou are the first person to give the Correct Answerand Explanation, then you are D . | D eligible fora mobile recharge. The amount of recharge is linked to the number of 3' V 056 friends and followers we have. It can varyfrom Rs.40 to Rs. 100. 0 7 5 More Details at http: //java. meritcampusxom/ dailydose Request: Please reviewthe previous comments before posting youranswer. Post m only if you think none ofthe previous comments are correct. Note: The processingofthe recharge can take up to 7 days. 26-Feb-2013 What will be the output of the following program? " Eclass Studentl-larks'I‘est ( ' static int count : 0; public static void main(String[] args) ( Marks marks = null; while (count <= 4) ( marks = createMarks(); try ( for (int i : 0; i < 5; i++) ( System. out. print(marks. marks[i] + ”—”); l } catch (NullPointerException npe) ( System. out. print(”NPE—”); ) catch (ArraylndexOutOfBoundsException aie) ( System. out. print("AOE-“); } catch (Exception ex) ( System. out. print(”E—”): } finally ( count++; l } private static Marks createMarks() ( if (count = 0) return null; ' if (count = 1) return new I-farks(); Marks marks = new Marks(); marks. marks : new int[count]; if (count > 3) ( marks. marks[0] = marks. marks[1] = marks. marks[2] = 3; l . return marks: 5 l E l Eclass Marks ( int marks[]r ) A NPE-0-AOE-Cl-O-AOE-0-0-0-AOE-0-0-0-0-AOE- {EZ NPE-NPE-0-0-AOE-O-O-0-AOE-3-3-3-O-AOE- L NPE-NPE-0-0-AOE-0-O-O-AOE-0-0-O-O-AOE- E NPE-0-E-0-0-E-0-0-0-E-O-O-O-0-E- Compilation Error or some other output not shown here
  16. 16. Ifyou are the first person to give the Correct Answer and Explanation. then you are eligible for a mobile recharge The amount of recharge is linked to the number of friends and followers we have it can vary from Rs 40 to Rs 100. 6 More Details 8 http: /flava. merifc: impus. com/ dailydose Daily Dose . _ Request: Please review the previous comments before posting your answer. Post 27_Feb_2o13 m 3 fl I. only if you think none of the previous comments are correct Note: The processing of the recharge can take up to 7 days Marks What will be the output of the following program? l ' ipublic class PrintLetters l public static void ma1n(String[] ars) ( Stringll args - {"i~. ", "13", 4: String[] input = ("A“, "J" “A". "I. " l: for (String element : args) l String matchedfilement - get: -latchedElement(args, element) . - Systc: n.out. pr: Lnt(“ " 0 (matchedfllement ' null " rnatchedfllcment : args [input. lengtl1 ; 4] ) ) r l private static String getMatched. Element(Str. i.ng[] input, String search) ( String result ””‘ for (int i r O: i < input. length; i+*) i if (search. equals (inputlil )) l result = inputlil + + i; if (1 > 1) ( System. ouC. print(” “ 0 result): return result. tx: i.-n() . equals("“) ' null : result: ‘i l lAl - AO- AO- A4- A4 A4- - - - C- C1- C1- C1- C1 C1- - - - C- E2- E2- E2- E2 E2- - - - C ‘B‘ - AO- AO- AO- AO- AO- A0 AO- - B1- 81- B1- 31- B1 B1- - - C2- C2- C2- C2 C2- - - - D3- D3- D3 D3- - - - - E4- E4 E4 - - - - - - F5 F5 l C l - AO- AO- AO- A0 AO- B1- B1- B1- B1 B1- C2- C2- C2- C2 C2- - D3- D3- D3 D3- ~ - E4- E4 E4- - - - F5 F5 lo} A0 31 C2- D3- - 54- - - rs l E" l Compilation Error because of using String array args
  17. 17. Ifyou are the first personto give the Correct Answerand Explanation, then you are . I eligible fora mobile recharge. The amount of recharge is linked to the numberof Dal V Dose friends and followers we have. It can varyfrom Rs. 40 to Rs.100. 0 7 7 More Details at http: //java. meritcampu5.com/ dailydose _ Request: Please reviewthe previous comments before posting youranswer. Post only if you think none of the previous comments are correct. Note: The processing of the recharge can take up to 7 days. 28-Feb-2013 class Tokens ( l public static void main(String[] args) 1 { I 1 StringTokenizer st = new StringTokenizer(”A~B#C~#D##E#~F~#G#H~ ~”, ”~#”); 1 while (st. hasMoreTokens()) { if (st. next: 'l‘oken(J . st: artswit: h("A") | | st: .next: Token(] . st: art: sWith(’‘D")) ( System. out. print: (st. next'I'oken() + ' ") ; l l I l 1 l lzl A~B= C D= =.= E== ~F G~'. —‘H~ ~ El B E lil A~B~‘. -'C D-‘-'= E#~F El A 0 El None of the above or it throws a run-time error
  18. 18. if you are the first person to give the Correct Answer and Explanatiomthenyou are . eligible fora mobile recharge. The amount of recharge is linked to the numberof Da"V Dose friends andfollowers we have. It can vary from Rs.40 to Rs. 100. 0 7 8 More Details at httpi/ /lava. meritcampus. com/ daiIydose Request: Please reviewthe previous comments before posting your answer. Post onlyif you think none ofthe previous comments are correct. Note: The processing ofthe recharge can take upto 7 days. 01-Mar-2013 What will be the output of the following program? "[ . . class Constructors E ( public static void main(String[] args) ( new A(3); new B(5, 6): new B(6, 7) . C(1, 2, 3); new C(3. 3, 4). B(4, 5): new (Ill, 1, 1): Eclass A : l 3 A(int: i) l print('1 - 2): l void printlint: i) { System. out: .prim: (i ¢ ' ‘')r l E l iolass 3 extends A El 1 Blint j, int: 1;) ( superlj); prin1:(k ' 4); } void C(int: j, int: k, int J. ) lprintlj + k + 1 — 3); l E l iclass C extends B l ( Clint: j, int k, int: 1) ( superrj, k): print(1 — 3): l void B('1nI: :1, int k) l print(i ' 6)? l Al 51024122a2361213202424-2 El 610241228361212424-2 C l Some other output not shown here Compilation Error
  19. 19. If you are the first person to give the Correct Answerand Explanation, then you are . | eligiblefora mobile recharge. The amount of recharge is Iinkedto the numberof D3‘ V Dose friends and followers we have. It can vary from Rs. 40 to Rs. 100. O 7 9 More Details at http: //lava. meritcampus. com/ dailydose Request: Please review the previous comments before posting your answer. Post only if you think none ofthe previous comments are correct. o2'Ma F2013 Note: The processing of the recharge can take upto 7 days. What will be the output of the following program? 5 import java. util. *; 5 public class Comparab1eTest ( ' public static void main(String[] args) ( 1.i. st<A> list = new ArrayList<A>(); 1ist. add(new A(5, 7)); 1ist. add(new A(3, 7)); 1ist. add(new A(5, 10)); 1ist. add(new A(10, 3) ) ; 1ist. add(new A(5, 4)); Collections. sort(1ist); System. out. println(1ist); Collections . reverse (list) ; SysteIn. out. print1n(1ist) ; System . out . print1n(Co11ect: ions . max (list) ) ; System. out. print]. n(Co11ect'. ions . min(1ist) ) ; E l : class A implements Comparab1e<A> ( ' int i, j; public A(int i, int j) ( this. i - i; this. j - j; ) public int compare'l‘o(A 0) I if (i ! - o. i) return o. i — i; return o. j — j, - l public String toString() ( return "[" + 1'. + ": " + j + "]"; ) [[3:7], [5:4], [5:7], [S:10], [10:3]] [[10:3], [S:10], [5:7], [5:4], [3:7]] [10:3] [3:7] Some other output not shown here
  20. 20. If you are the first person to give the Correct Answerand Explanation, then you are eligible fora mobile recharge. The amount of recharge is Iinkedto the numberof friends andfollowers we have. It can varyfrom Rs. 40 to Rs. 100. More Details at http: //lava. merit(ampus. com/ dailydose Request: Please review the previous comments before postingyouranswer. Post only if you think none ofthe previous comments are correct. Note: The processing ofthe recharge can take upto 7 days. merit What will be the output of the following program? import: java. uti1. ‘: épublic class Collections'l‘est { public static void main(Strin9[i args) ( List<A> l : new ArrayList<A>() , - l. add(new A(5, 4)): 3 l. add(l. get(0)). ' l. add(new A(6, 0)); l. add(new A(5, 4)); l. add(new A(6)); 1 Set<A> s = new HashSet'. <A>(), ' 3 s. addAll(l); SysteIn. out. print("1 = “ ¢ 1.size(l + ‘ s = ‘+ s. size()), ' « i l lclass A l ' int 1, j: public A(int i, int j) lthis. i : i; this. j = j: i public A(int i) ( this. i : i; ) Daily Dose 080 03-Ma r-2013 Tl I = S s = 4 El I = 5 s = 5 _cl I = 3 s = 3 El I = 5 s = 3 El Compilation error or run-time error

×