Select chapter



basics (7.papers)
constructors (1.papers)
packages (1.papers)
inheritance (7.papers)
misc (3.papers)
exceptions (5.papers)
threads (4.papers)
overloading (1.papers)
jsp (3.papers)
servlets (9.papers)
jdbc (2.papers)
util (1.papers)
xml (2.papers)
IO stream (3.papers)
Hide

Sponsored Links


  

java util interview questions and answers

1
Predict the output of the following code snippet:
import java.util.*;
public class SampleDate{
 public static void main(String args[]){
  Date dt = new Date();
  String DATE_FORMAT = "dd/mm/yyyy";
  SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
  System.out.println("It is " + sdf.format(dt) );
 }
}
  1. The code prints today's day in the month/Month in year/year
  2. The code prints today's day in the year/minute in Hour/year
  3. The code prints today's day in the month/minute in Hour/year
  4. Gives Compilation Error
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
7
What will be printed on the console when compile and run the given code:
public class Test{
 public static void main(String[] args) {
  for (int i=0; i<100; i++)
   System.out.println(1+(int)(Math.random( ) * 10));
 }
}
  1. Generates 100 random numbers from 1 to 10 exclusive 10
  2. Generates 100 random numbers from 1 to 10 inclusive 10
  3. Generates 10 random numbers from 1 to 100 inclusive 100
  4. Generates 10 random numbers from 1 to 100 exclusive100
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Read more papers :