You are on page 1of 9

04/04/11 6:03 PM Questions  on  Data  Structure     1. What is a Data Structure? a.

A data structure is a way of organizing data that considers not only the items stored, but also their relationship to each other. Advance knowledge about the relationship between data items allows designing of efficient algorithms for the manipulation of data. 2. In RDBMS, what is the efficient data structure used in the internal storage representation? a. B+ tree. 3. Minimum number of queues needed to implement the priority queue? a. Two. One queue is used for actual storing of data and another for storing priorities. 4. What is the data structures used to perform recursion? a. Stack. Because of its LIFO (Last In First Out) property it remembers its 'caller' so knows whom to return when the function has to return. 5. How to find the number of possible tree in the given tree. a. The number of possible tree = (2 power of n) - n.

Numerical Analysis. Database Management System. 5. midsqure. Here is an example of implementing a binary tree: Consider an attay : a[n].digit analysis)and also records are retrieved using same hash function. Graphics. Place the root in first position. 4. 2. What is hashing? Hashing is a way retrieving records from memory in faster way. Operating System. 3. Compiler Design. Record is inserted into memory by using hash function(division. Artificial Intelligence. List out the areas in which data structures are applied extensively? 1.04/04/11 6:03 PM Questions on Algorithms 1. Simulation 2. 7. Is it possible to implement trees using arrays ? If yes. 3. and let the current position to be i = 0. Statistical analysis package. 5. place left node at the position: 2i+1 place right node at the position: 2i+2. 4. Whether Linked List is linear or Non-linear data structure? According to Access strategies Linked list is a linear one. . In tree construction which is the suitable efficient data structure? Linked list is the efficient data structure. how? Yes. According to Storage Linked List is a Non-linear one. it is possible. 8. 6.folding.

Repeat these steps. .

and when is it used? • The purpose of garbage collection is to identify and discard objects that are no longer needed by a program so that their resources can be reclaimed and reused. What is the purpose of garbage collection in Java. • If you want faster access use StringBulder. 6. 4. What are the new features introduced in Java 5? • Generics. Methods in StringBuffer are Synchronized& thread safe. An Interface can only declare constants and instance methods.04/04/11 6:03 PM Questions on Java Basics 1. Annotations. What is the difference between StringBuffer and StringBuilder class? • StringBuilder is a feature of Java 5. What is the difference between an Interface and an Abstract class? • An abstract class can have instance methods that implement a default behavior. 2. TypesafeEnums. • They both are the same. 5. Variable Arguments. Relationship between JRE& JVM. 3. A ClassNotFoundException means that the classloader cannot load class A. A ClassDefNotFoundError means that the classloader can load class A but cannot instantiate it because it cannot load the other classes that class A depend on. Static Import. • Methods in StringBuilder are not Synchronized& not thread safe. . What is ClassDefNotFoundException and NoClassDefFoundError and explain differences between these two? • Given a class A. Autoboxing/Unboxing. Enhanced for Loop. but cannot implement default behavior and all methods are implicitly abstract.

10. Static block variables initialize at first Static method of variables initialize second Static variables initialize third Constructor variables initialize at fourth and then Instance Variables initialize at last. You can't change value of a final variable (is a constant). not an object. . What is final? A final class can't be extended i.. What is the order of initialization of variables in Java • • • • • 9. not one for each object no matter how many instance of a class might exist.e. So Enumeration is used when ever we want to make Collection objects as Read-only. A final method can't be overridden when its class is inherited. Tell me the differences between enumeration and iteration?Which can use where in realtime? • Enumeration acts as Read-only interface because it has the methods only to travels and fetch the objects where as using Iterator we can manipulate the objects also like adding and removing the objects. What is static in java? Static means one per class. Static methods are attached to a class. final class may not be sub classed. This means that you can use them without creating an instance of a class. • 8.7.

public private or protected). private. • public : Public class is visible in other packages. State the significance of public. What are transient variables in java? Transient variables are variable that cannot be serialized. What is synchronization? Synchronization is the ability to control the access of multiple threads to shared resources. default :What you get by default i. without any access modifier (i.     .e.e. This access is provided even to subclasses that reside in a different package from the class that owns the protected feature... 14.   What  is  a  daemon  thread?       These  are  the  threads  which  can  run  without  user  intervention. 13. default modifiers both singly and in combination and state the effect of package relationships on declared items qualified by these modifiers. •   •   •   12.It means that it is visible to all within a particular package. at a time only one thread will be able to access a shared resource.11.  The  JVM  can  exit   when  there  are  daemon  thread  by  killing  them  abruptly. protected. With synchronization. field is visible everywhere (class must be public too) private : Private variables or methods may be used only by an instance of the same class that declares the variable or method. Synchronization stops multithreading. protected : Is available to all classes in the same package and also available to all subclasses of the class that owns the protected feature. A private feature may only be accessed by the class that owns the feature.

  What  is  mutable  object  and  immutable  object?       If  a  object  value  is  changeable  then  we  can  call  it  as  Mutable  object.  it  is  immutable   object.  It  is  possible  for  programs  to  use  up  memory  resources  faster  than  they  are   .  …)  If  you  are  not  allowed  to  change  the  value  of  an  object.     20.  String.  Float. Is  null  a  keyword?     The  null  value  is  not  a  keyword. This falls in the creational pattern of the design pattern.  …)     16.15. } // all non static methods … } 18.  (Ex. There will be only one instance for that entire JVM.  Integer. private Singleton() { } public static Singleton getInstance() { return s..   What  are  the  approaches  that  you  will  follow  for  making  a  program  very   efficient?     By  avoiding  too  much  of  static  methods  avoiding  the  excessive  and  unnecessary   use  of  synchronized  methods  Selection  of  related  classes  based  on  the  application   (meaning  synchronized  classes  for  multiuser  and  non-­‐synchronized  classes  for  single   user)  Usage  of  appropriate  design  patterns  Using  cache  methodologies  for  remote   invocations  Avoiding  creation  of  variables  within  a  loop  and  lot  more.     19. What is singleton? It is one of the design pattern.  (Ex. You can achieve this by having the private constructor in the class.   StringBuffer.   17.   Is  sizeof  a  keyword?     The  sizeof  operator  is  not  a  keyword. public class Singleton { private static final Singleton s = new Singleton()..   Does  garbage  collection  guarantee  that  a  program  will  not  run  out  of  memory?       Garbage  collection  does  not  guarantee  that  a  program  will  not  run  out  of   memory. For eg..

    26.garbage  collected.   What  is  the  difference  between  instanceof  and  isInstance?     .   or  array  type  reference.   Which  class  is  extended  by  all  other  classes?       The  Object  class  is  extended  by  all  other  classes.     22.     24.   What  restrictions  are  placed  on  method  overriding?     Overridden  methods  must  have  the  same  name.   The  overriding  method  may  not  limit  the  access  of  the  method  it  overrides.  to  smaller  values.  The   overriding  method  may  not  throw  any  exceptions  that  may  not  be  thrown  by  the   overridden  method.  interface.   What  are  the  disadvantages  of  using  threads?       DeadLock.     23.     27.    It  is  also  possible  for  programs  to  create  objects  that  are  not  subject   to  garbage  collection.  such  as  double  values.   What  is  the  purpose  of  the  Runtime  class?       The  purpose  of  the  Runtime  class  is  to  provide  access  to  the  Java  runtime  system.  and  return  type.  and  the   InputStream/OutputStream  class  hierarchy  is  byte-­‐oriented.  casting  between  primitive  numeric  types  and   casting  between  object  references.     21.   What  is  the  difference  between  the  Reader/Writer  class  hierarchy  and  the   InputStream/OutputStream  class  hierarchy?       The  Reader/Writer  class  hierarchy  is  character-­‐oriented.  argument  list.  Casting  between  numeric  types  is  used  to  convert   larger    values.   What  is  casting?       There  are  two  types  of  casting.  such  as  byte  values.  Casting   between    object  references  is  used  to  refer  to  an  object  by  a  compatible  class.     25.

 This  method  is  the   dynamic  equivalent  of  the  Java  language  instanceof  operator.   instanceof  is  used  to  check  to  see  if  an  object  can  be  cast  into  a  specified  type   without  throwing  a  cast  class  exception.  It  returns  false   otherwise.  The  method  returns  true  if   the  specified  Object  argument  is  nonnull  and  can  be  cast  to  the  reference  type   represented  by  this  Class  object  without  raising  a  ClassCastException.   .  isInstance()  determines  if  the  specified  object   is  assignment-­‐compatible  with  the  object  represented  by  this  Class.