java interview questions

Set 10 – Java, Oracle, Unix Interview Questions

1. What is the return type of remove(Object) method of Collection interface? Choose the right option. 1. boolean 2. Object 3. int 4. Integer 2. What is the output of the following snippet of code? Choose the right option. List numbers1 = new ArrayList(); numbers1.add(2); numbers1.add(1); numbers1.set(1, 2); System.out.println(numbers1); 1. [1, 2] 2. [1, 1] …

Set 10 – Java, Oracle, Unix Interview Questions Read More »

Set 9 – Java, Oracle, Unix Interview Questions

1. The method that writes a string of DataOutputStream is 1. writeLine(String) 2. write(String) 3. writeString(String) 4. writeBytes(String) 2. What about the following snippet of code? Choose the right one that is true. Hashtable ht = new Hashtable(); ht.put(“marks”, 40); ht.put(“marks”, 50); System.out.println(ht.get(“marks”)); 1. prints 40 2. prints 50 3. Compilation error 4. Throws exception …

Set 9 – Java, Oracle, Unix Interview Questions Read More »

Set 8 – Java, Oracle, Unix Interview Questions

1. null key is not accepted by which data structure? 1. HashMap 2. Hashtable 3. List 4. Set 2. What is the output of the following snippet of code? List myList = new ArrayList(); List yourList = new ArrayList(); myList.add(10); myList.add(20); yourList.add(30); yourList.add(40); myList.addAll(yourList); System.out.println(yourList); 1. [10, 20 ] 2. [30, 40 ] 3. [10, …

Set 8 – Java, Oracle, Unix Interview Questions Read More »

Set 7 – Java, Oracle, Unix Interview Questions

1. What is the return type of insertElementAt(Object, int) method of Vector? 1. Object 2. boolean 3. void 4. int 2. Observe the following code snippet and choose the right option. List fruits = new ArrayList(); fruits.add(“mango”); ListIterator li1 = fruits.listIterator(); while(li1.hasNext()) { fruits.add(“apple”); System.out.println(li1.next()); } 1. Compiles and at execution throws ConcurrentModificationException 2. prints …

Set 7 – Java, Oracle, Unix Interview Questions Read More »

Set 6 – Java, Oracle, Unix Interview Questions

1. What is the default capacity and increment rate of Vector? 1. 10 and 10 2. 10 and 11 3. 11 and 11 4. 10 and 5 2. What is the return type of add(Object) method of interface Collection? 1. void 2. boolean 3. Object 4. int 3. Choose more appropriate option. currentThread() method of …

Set 6 – Java, Oracle, Unix Interview Questions Read More »

Set 4 – Java, Oracle, Unix Interview Questions

1. What is the index position of element 10 in the Stack? Stack st = new Stack(); st.push(10); st.push(20); st.push(30); 1. 0 2. 1 3. 2 4. 3 2. With what you can fill up the blank so that the output is Hyderabad. List cities = new ArrayList(); cities.add(“Hyderabad”); ——- abc = cities.get(0); System.out.println(abc); 1. …

Set 4 – Java, Oracle, Unix Interview Questions Read More »

Set 3 – Java, Oracle, Unix Interview Questions

1. Which interface is not in the Collection hierarchy? 1. List 2. Set 3. Map 4. Queue 2. What is the output of the following snippet of code? Hashtable ht = new Hashtable(); StringBuffer sb1 = new StringBuffer(“hello”); ht.put(sb1, “sir”); Enumeration e = ht.keys(); while(e.hasMoreElements()) { Object obj1 = e.nextElement(); Object obj2 = ht.get(obj1); System.out.println(obj1 …

Set 3 – Java, Oracle, Unix Interview Questions Read More »

Exceptions Interview Questions

What is an exception?The English literature meaning is "something that happens unusually (very rarely)". It is the same meaning with Java also. Exception can be defined as a problem occurring at runtime that prevents the execution of the program. Or to say, an exception is a runtime problem (not compile time as compilation is already …

Exceptions Interview Questions Read More »

Object Casting Polymorphism Interview Questions

Note: Explanation is given avoiding more buzz words. Easily understandable manner. Object Casting Polymorphism Interview Questions What is casting? Converting one data type (or object) to the other is known as casting. It is required in a programming language as the user entered data may be in different form than required in coding. How many …

Object Casting Polymorphism Interview Questions Read More »