Questions of Test: Core Java Interview Questions

More >>

1

java.sql.ResultSet is class or interface

2

What is WeakhashMap

3

When can an object's finalize() method be invoked ?.

4

A user needs to store 20 key value entries in one object and 35000 key value entries in another object. 
Which implementations from collections framework should he choose keeping performance in mind ?  
The key would not be a null value.

5

Jdk1.5 has introduced class data sharing which reduces the start up time for java applications and to reduce the memory footprint

6

What characteristics of garbage collection have changed in jdk 5.0

7

public class GeekTryCatch { 
 
public void doSomething(){ 
   
  int iCount = 10 ; 
  int result = 20; 
  try{ 
    
   
         for(int i=0 ; i<= 10 ; i++){ 
     
         result = i/iCount; 
         iCount --; 
   } 
   
  }finally{ 
   System.out.print("Result "+result); 
  } 

 
public static void main(String args[]){ 
   
  GeekTryCatch geekTryCatch = new GeekTryCatch(); 
  geekTryCatch.doSomething(); 

 

 
Will the above code compile and something be printed in the Result ?

8

I want to split the incoming string which is an IP address into token. 
The string is 192.168.10.28. 
 
My method to this task is  
 
public void doSomething(){ 
   
         StringTokenizer st = new StringTokenizer("192.168.10.28","."); 
         while (st.hasMoreTokens()) { 
          System.out.println(st.nextToken()); 
      } 
   

 
 
Am I missing something here ?

9

What is System, out and print in System.out.print ?

10

public static void main(String args[]){ 
 
String varString1 = "Geek"; 
String varString2 = new String("Geek"); 
String varString3 = "Geek"; 
 
if (varString1 == varString2) { 
  System.out.println("The strings are equal_1"); 
} else { 
  System.out.println("The strings are unequal_1."); 

if (varString1 == varString3) { 
  System.out.println("The strings are equal_2."); 
} else { 
  System.out.println("The strings are unequal_2."); 

if (varString1 .equals(varString2)) { 
  System.out.println("The strings are equal_3."); 
} else { 
  System.out.println("The strings are unequal_3."); 

 
What will be the output here ? 

More >>