gs gs111 Types of Classes (Using Java) - Collection Classes - 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.
import java.util.*; public class Collection { public static void main(String args[]) { String a[] = {"Sa","nf","ou","nd","ry"}; Arrays.sort(a); for(int i=0;i<5;i++) { System.out.print(a[i]); } } }
import java.util.*; public class Collection2 { public static void main(String args[]) { LinkedList l = new LinkedList(); l.add("NVAEducation"); l.add(10); l.add(20); l.add(30); Collections.shuffle(l); Iterator i = l.iterator(); while(i.hasNext()) System.out.println(i.next()); } }
10 20 30 NVAEducation
20 30 10 NVAEducation
30 NVAEducation 10 20
import java.util.*; public class MainCall { public static void main(String args[]) { LinkedList l = new LinkedList(); l.add("S"); l.add("a"); l.add("n"); l.add("f"); l.add("o"); l.add("u"); l.add("n"); l.add("d"); l.add("r"); l.add("y"); Collections.reverse(l); Iterator i = l.iterator(); while(i.hasNext()) System.out.print(i.next()); } }
S a n f o u n d r y
y r d n u o f n a S
import java.util.*; public class MainExecute { public static void main(String args[]) { LinkedList l = new LinkedList(); String s = "NVAEducation"; for(int i=0;i<s.length();i++) { l.add(s.charAt(i)); } System.out.println(l); } }
import java.util.*; public class LinkedList { public static void main(String args[]) { LinkedList l = new LinkedList(); l.add(1); l.add(2); l.add(4); l.add(5); l.add(3); l.remove(3); System.out.println(l); } }
import java.util.*; public class retainAll { public static void main(String args[]) { LinkedList l = new LinkedList(); String s = "NVAEducation"; for(int i=0;i<s.length();i++) { l.add(s.charAt(i)); } LinkedList a = new LinkedList(); a.add('S'); a.add('f'); a.add('n'); a.add('o'); l.retainAll(a); System.out.println(l); } }
import java.util.*; public class Find { public static void main(String args[]) { LinkedList l = new LinkedList(); l.add("S"); l.add("a"); l.add("n"); l.add("f"); l.add("o"); l.add("u"); l.add("n"); l.add("d"); l.add("r"); l.add("y"); Iterator i = l.iterator(); while(i.hasNext()) { if(i.next().equals("n")) System.out.println("Found 'n'"); } } }
Found 'n' Found 'n'
import java.util.*; public class hashCode { public static void main(String args[]) { LinkedList l = new LinkedList(); l.add("NVAEducation"); System.out.println(l.hashCode()); l.clear(); System.out.println(l.hashCode()); l.add("NVAEDUCATION"); System.out.println(l.hashCode()); l.clear(); System.out.println(l.hashCode()); } }
-599207512 1 -2107580024 1
-599207512 -599207512 -599207512 -599207512
1 1 1 1
-599207512 1 -599207512 1