Java Concepts
Test your knowledge of Java programming concepts including collections, OOP principles, access modifiers, garbage collection, and Java language features.
Questions
Which of the following interfaces is not a part of the collection interface?
- Set
- List
- Queue
- ArrayDeque
- Map
Which of the following is the superclass for all the classes in Java?
- Object
- Util
- Lang
- Swing
- None of these
Which of the following is not a feature of JAVA?
- Platform independent
- Multithreaded
- Explicit pointers
- Object oriented
- None of these
When a method is declared as public, it can be accessed from its
- class
- subclass
- package
- outside package
- all of the above
Which of the following collections does not allow duplicacy?
- Linkedlist
- Hashset
- Vector
- Queue
- ArrayList
Which of the following is not an object oriented programming language?
- Java
- C
- C++
- PHP5
- Cecil
Which of the following bit manipulations is equal to doubling the number i?
- i<<1
- i>>1
- i<<2
- i>>2
- none of these
Which of the following is a code snippet for calculating the hashcode value of a string employed by Java compiler?
- public int hashCode(String s) { int h = 0; char val[] = s.toCharArray(); for (int i = 0; i < value.length; i++) { h = 31 * h + val[i]; } } return h; }
- public int hashCode(String s) { int h = 0; char val[] = s.toCharArray(); for (int i = 0; i < value.length; i++) { h = 27 * h + val[i]; } } return h; }
- public int hashCode(String s) { int h = 0; char val[] = s.toCharArray(); for (int i = 0; i < value.length; i++) { h = 131 * h + val[i]; } } return h; }
- public int hashCode(String s) { int h = 0; char val[] = s.toCharArray(); for (int i = 0; i < value.length; i++) { h = 231 * h + val[i]; } } return h; }
- public int hashCode(String s) { int h = 0; char val[] = s.toCharArray(); for (int i = 0; i < value.length; i++) { h = 531 * h + val[i]; } } return h; }
The decreasing order of the following access specifiers is
- public > protected > package-private > private
- public > protected > private > package-private
- public > private > package-private > protected
- public > private > protected > package-private
- package-private > private > package-private > protected
Which of the following is used to explicitly call the garbage collector in Java?
- System.gc()
- System.garbage();
- System.gcollector()
- System.memoryfree();
- None of these
What is the chronological order in context to the year of development of the languages C, C++ and JAVA?
- C++, C, JAVA
- C, JAVA, C++
- C++, JAVA, C
- JAVA, C++, C
- C, C++, JAVA
JDBC, Servlets, JSP's are present in which edition of JAVA?
- JAVA SE(Standard Edition)
- JAVA ME(Micro edition)
- JAVA EE(Enterprise Edition)
- All of the above
- None of these
What is the default scope of a method in Java?
- Private
- Public
- Protected
- Package-private
- None of these
When a method is declared as private, it can be accessed from its
- class
- subclass
- package
- anywhere
- all of the above
Which of the following has method signatures but not their implementations?
- Interface
- Abstract data type
- Class
- API
- Library