Interview Questions and Answers - Order By Newest Q561. Is java.util.Date an abstract Class ? Is java.util.Calendar an abstract Class ? Core Java
Ans. Date is not a abstract class whereas Calendar is. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   date   calendar   abstract class Q562. What will the following code print ? java.util.Calendar c = java.util.Calendar.getInstance(); c.add(Calendar.MONTH, 5); System.out.println(c.getTime()); Core Java
Ans. Date and Time after 5 months from now. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   date   calendar   scjp   ocjp   coding   code Q563. Which of the following code is correct ? a. DateFormat df = DateFormat.getInstance(); b. DateFormat df = DateFormat.getDateInstance(); c. DateFormat df = DateFormat.getInstance(DateFormat.FULL); d. DateFormat df = DateFormat.getDateInstance(DateFormat.FULL); Core Java
Ans. All except c are correct. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   date   dateformat Q564. What is the use of parse method in DateFormat ?
Ans. It is used to parse String to get the Date Object with initialized date. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   date   dateformat Q565. Which of the following is not a valid java.util.Locale initialization ? a. new Locale () b. new Locale ( String language ) c. new Locale ( String language , String country ) Core Java
Ans. a i.e new Locale() Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   locale   java.util Q566. Which of the following is not a valid NumberFormat initialization ? a. NumberFormat.getInstance() b. NumberFormat.getDateInstance() c. NumberFormat.getCurrencyInstance() d. NumberFormat.getNumberInstance() Core Java
Ans. b i.e NumberFormat.getDateInstance() Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   java.util.numberformat Q567. What will the following code print ? public static void main(String[] args){ Integer i1 = new Integer("1"); Integer i2 = new Integer("2"); Integer i3 = Integer.valueOf("3"); int i4 = i1 + i2 + i3; System.out.println(i4); } Core Java
Ans. 6 Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   int   integer   scjp   ocjp Q568. Which of the following syntax are correct ?a. LinkedList<Integer> l=new LinkedList<int>();b. List<Integer> l=new LinkedList<int>();c. LinkedList<Integer> l=new LinkedList<Integer>();d. List<Integer> l = new LinkedList<Integer>(); Core Java
Ans. All are correct. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   generics   linkedlist   list   collections basic Q569. Which of the following code is correct ? a. Date date = DateFormat.newInstance(DateFormat.LONG, Locale.US).parse(str); b. Date date = DateFormat.newInstance(DateFormat.LONG, Locale.US).format(str); c. Date date = DateFormat.getDateInstance(DateFormat.LONG, Locale.US).parse(str); Core Java
Ans. c Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   java.util   date   dateformat Q570. Which methods of the Pattern class have equivalent methods in the String class? Core Java
Ans. split() and macthes() Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   io   string class   string   pattern Q571. Can we compare Integers by using equals() in Java ? Core Java
Ans. Yes for the Wrapper class Integer but not for the primitive int. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   wrapper classes   equalsVery Frequently asked. Favorite question in walkins and telephonic interviews. Usually among first few questions. Asked in different variants. Must know for intermediate and expert professionals.Among Top 10 frequently asked questions. Q572. What is rule regarding overriding equals and hashCode method ? Core Java
Ans. A Class must override the hashCode method if its overriding the equals method. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   hashcode  hash code   equals   collections Asked in 44 Companies intermediate   frequent Try 1 Question(s) Test Q573. What is the difference between Collection and Collections ? Core Java
Ans. Collection is an interface whereas Collections is a utility class. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections Asked in 1 Companies Q574. Is Java a statically typed or dynamically typed language ?
Ans. Statically typed Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java Q575. How can we reverse the order in the TreeMap ?
Ans. Using Collections.reverseOrder() Map tree = new TreeMap(Collections.reverseOrder()); Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   map   treemap Try 1 Question(s) Test Q576. TreeMap orders the elements on which field ?
Ans. Keys Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   map   treemap Q577. How TreeMap orders the elements if the Key is a String ?
Ans. As String implements Comparable, It refers to the String compareTo method to identify the order relationship among those elements. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   comparable interface   treemap   compareto Q578. Can we add heterogeneous elements into TreeMap ?
Ans. No, Sorted collections don't allow addition of heterogeneous elements as they are not comparable. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   comparable interface   treemap Q579. Will it create any problem if We add elements with key as user defined object into the TreeMap ?
Ans. It won't create any problem if the objects are comparable i.e we have that class implementing Comparable interface. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   treemap   comparable interface Q580. Can we have null keys in TreeMap ? Core Java
Ans. No, results in exception. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   treemap Asked in 6 Companies Basic   frequent Q581. Can value be null in TreeMap ? Core Java
Ans. Yes. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   treemap   yes-no Q582. Which interface TreeMap implements ?
Ans. TreeMap implements NavigableMap, SortedMap, Serializable and Clonable. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   treemapFrequently asked in Phone Interviews. Q583. What are the various Auto Wiring types in Spring ?
Ans. By Name , By Type and Constructor. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   spring   spring container   dependency injection   auto wiring   auto wiring types   general electric   ge Q584. Is It Good to use Reflection in an application ? Why ? Core Java
Ans. no, It's like challenging the design of application. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   reflection api   yes-no   architecture Asked in 1 Companies intermediate Q585. Why is Reflection slower ?
Ans. Because it has to inspect the metadata in the bytecode instead of just using precompiled addresses and constants. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   reflection   reflection api   architecture Q586. How many SessionFactory and Session objects are created ? Java EE
Ans. Single SessionFactory object and multiple session objects for opening different session. Hibernate creates new Session object per thread. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  hibernate   sessionfactory hibernate   session hibernate Q587. What is the difference between int[] x; and int x[]; ? Core Java
Ans. No Difference. Both are the acceptable ways to declare an array. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   array   arrays   array declaration   difference between Asked in 3 Companies basic Q588. What are the annotations used in Junit with Junit4 ?
Ans. @Test The Test annotation indicates that the public void method to which it is attached can be run as a test case. @Before The Before annotation indicates that this method must be executed before each test in the class, so as to execute some preconditions necessary for the test. @BeforeClass The BeforeClass annotation indicates that the static method to which is attached must be executed once and before all tests in the class. @After The After annotation indicates that this method gets executed after execution of each test. @AfterClass The AfterClass annotation can be used when a method needs to be executed after executing all the tests in a JUnit Test Case class so as to clean-up the set-up. @Ignores The Ignore annotation can be used when you want temporarily disable the execution of a specific test. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   junit   jnuit4   junit annotations Q589. What is asynchronous I/O ?
Ans. It is a form of Input Output processing that permits other processing to continue before the I/O transmission has finished. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   io   file   fileio   java7   architecture Q590. If there is a conflict between Base Class Method definition and Interface Default method definition, Which definition is Picked ?
Ans. Base Class Definition. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   java8   default methods