aspose file tools*
The moose likes Java in General and the fly likes here are some interview questions asked?any one kindly reply to these quesitons?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "here are some interview questions asked?any one kindly reply to these quesitons??" Watch "here are some interview questions asked?any one kindly reply to these quesitons??" New topic
Author

here are some interview questions asked?any one kindly reply to these quesitons??

senthil sen
Ranch Hand

Joined: Oct 10, 2002
Posts: 184
1.difference between a process and a thread?
2.what are checked and unchecked exceptions?
3.Is synchronised a modifier?indentifier??what is it??
4.What is meant by resource leak?
5.what is singleton class?where is it used?
6.Name the null interfacess in java?what are they?
7.how to avoid deadlock?
8.Garbage collection thread belongs to which priority..min?normal?max?
9.What is meant by time slicing?
10.what is a compilation unit?
11.is string a wrapper class?
12.how can you retrieve warning in jdbc?
13.is ther any tool in java that can create reports?
14.what is JTS?where is it used?
15.why java does not have multiple inheritance?
16.why java is not a 100% oops?
17.what is a resource bundle?
Jon Strayer
Ranch Hand

Joined: Dec 04, 2002
Posts: 133
Maybe you should do your own homework.


Jon
Debashish Chakrabarty
Ranch Hand

Joined: May 14, 2002
Posts: 230

Hi,
These questions were lying (unattended ) for quite some time and I was looking for some exercise..so here are my takes. Ranchers, feel free to post your observations on my answers..please do correct (and ridicule ) them if any of these is/are wrong for everybody's sake..many people may apprecitae yr effort..Here we go:
1.Difference between a process and a thread?
I remember having read this answer somewhere. "Threads are like tiny ropes. A Process would denote a rope made out from these threads." Fun apart, a process can contain multiple threads. Also a process gets its own memory address space while a thread doesn't.
2.What are checked and unchecked exceptions?
Checked exceptions are the ones which you expect beforehand to be raised when an exceptional condition occurs and so write your code in a try-catch block to handle that sufficiently. For example: InsuffucientBalanceException which might be raised when money is being withdrawn from a bank account and the account has insufficient balance. Checked exceptions are sub classes of Exception.
Unchecked exceptions are the ones which cannot be handled in the code. These are rather unexpected exceptions like NullPointerException, OutOfMemoryError, DivideByZeroException, typically, programming errors. Unchecked exceptions are subclasses of RunTimeExceptions.
3.Is synchronised a modifier?indentifier??what is it??
It's a modifier. Synchronized methods are methods that are used to control access to an object. A thread only executes a synchronized method after it has acquired the lock for the method's object or class. Synchronized statements are similar to synchronized methods. A synchronized statement can only be executed after a thread has acquired the lock for the object or class referenced in the synchronized statement.
4.What is meant by resource leak?
I don't know.. any rancher would like to try and help?
5.What is singleton class?where is it used?
Singleton is a design pattern meant to provide one and only one instance of an object. Other objects can get a reference to this instance through a static method (class constructor is kept private). Why do we need one? Sometimes it is necessary, and often sufficient, to create a single instance of a given class. This has advantages in memory management, and for Java, in garbage collection. Moreover, restricting the number of instances may be necessary or desirable for technological or business reasons--for example, we may only want a single instance of a pool of database connections.
6.Name the null interfacess in java?what are they?
No idea..ranchers come to my rescue..
7.How to avoid deadlock?
  • Don't go to sleep holding a lock
  • Coordinate thread access to synchronized methods using wait and notify.


  • 8.Garbage collection thread belongs to which priority..min?normal?max?The Java garbage collection is implemented as a low priority thread
    9.What is meant by time slicing?
    Its a task scheduling method. With time slicing, or "Round-Robin Systems", several processes are executed sequentially to completion. Each executable task is assigned a fixed-time quantum called a time slice in which to execute.

    10.What is a compilation unit?
    The smallest unit of source code that can be compiled, i.e. a .java file.
    11.Is string a wrapper class?
    String is a class, but not a wrapper class. Wrapper classes like (Integer) exist for each primitive type. They can be used to convert a primitive data value into an object, and vice-versa.
    12.how can you retrieve warning in jdbc?
    Write my JDBC code in a try-catch block and catch the SQLExcpetions
    13.Is there any tool in java that can create reports?
    Yes there are third party tools available.
    14.What is JTS? Where is it used?
    JTS specifies the implementation of a transaction manager which supports the Java Transaction API (JTA) and implements the Java mapping of the Object Management Group (OMG) Object Transaction Service (OTS) specification (at the level below the API).
    15.Why java does not have multiple inheritance?
    The Java design team strove to make Java:
  • Simple, object oriented, and familiar
  • Robust and secure
  • Architecture neutral and portable
  • High performance
  • Interpreted, threaded, and dynamic


  • The reasons for omitting multiple inheritance from the Java language mostly stem from the "simple, object oriented, and familiar" goal. As a simple language, Java's creators wanted a language that most developers could grasp without extensive training. To that end, they worked to make the language as similar to C++ as possible (familiar) without carrying over C++'s unnecessary complexity (simple).
    In the designers' opinion, multiple inheritance causes more problems and confusion than it solves. So they cut multiple inheritance from the language (just as they cut operator overloading). The designers' extensive C++ experience taught them that multiple inheritance just wasn't worth the headache.
    16.Why java is not a 100% oops?Many people say this because Java uses primitive types such as int, char, double. But then all the rest are objects. Confusing question..
    17.What is a resource bundle?
    In its simplest form, a resource bundle is represented by a text file containing keys and a text value for each key.
    Regards
    [ January 31, 2003: Message edited by: Debashish Chakrabarty ]

    Debashish
    SCJP2, SCWCD 1.4, PMP, ITIL Foundation
    Ilja Preuss
    author
    Sheriff

    Joined: Jul 11, 2001
    Posts: 14112
    Originally posted by Debashish Chakrabarty:
    16.Why java is not a 100% oops?Many people say this because Java uses primitive types such as int, char, double. But then all the rest are objects. Confusing question..

    There are more concepts in Java which aren't ooo there, but are in more OO languages (like Smalltalk, for example): classes and blocks aren't objects, control statements (if, while etc.) aren't implemented as methods, for example.


    The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
    Ashok Mash
    Ranch Hand

    Joined: Oct 13, 2000
    Posts: 1936
    Originally posted by Debashish Chakrabarty:
    6.Name the null interfacess in java?what are they?
    No idea..ranchers come to my rescue..

    Now, I am not sure about the answer, but still posting this because I believe in collective thinking.
    To be honest, I haven't heard the expression 'null interfaces' before. If I were to answer this question at an interview, I would ask then interviewer to clarify what he/she meant, as I haven't heard this before.
    Now, another option is to talk about java interfaces that do not have an implementation, for example, 'Throwable' or 'Serializable'. From API doc, "java.io.Serializable interface serialization interface has no methods or fields and serves only to identify the semantics of being serializable.". I guess this is what the question is about.
    Hope this helps,
    Ashok.


    [ flickr ]
    Steve Luke
    Bartender

    Joined: Jan 28, 2003
    Posts: 4181
        
      21

    6.Name the null interfacess in java?what are they?
    No idea..ranchers come to my rescue..

    Are these the Comparable, Serializable, etc... The interfaces with no methods to implement but signal that this class can be used in such a way?


    Steve
    Mani Ram
    Ranch Hand

    Joined: Mar 11, 2002
    Posts: 1140
    Originally posted by Debashish Chakrabarty:

    6.Name the null interfacess in java?what are they?
    No idea..ranchers come to my rescue..

    A null interface has no methods or fields and serves only to identify the semantics of that interface. (eg: java.io.Serializable ).
    The proper name for this is Marker Interface
    Debashish Chakrabarty
    Ranch Hand

    Joined: May 14, 2002
    Posts: 230

    So it was a question about Marker interfaces afterall.. I remember having read the term "tagging interface" for such interfaces somewhere...Here are few more such interfaces:
  • java.rmi.Remote
  • java.util.EventListener
  • java.lang.Cloneable

  • Thanks to all posts. There is one question (q.4)that's still unanswered..anybody taking a plunge? BTW I am planning to take on this too..I hope to get yr responses there also..
    Regards,
    [ January 31, 2003: Message edited by: Debashish Chakrabarty ]
    David O'Meara
    Rancher

    Joined: Mar 06, 2001
    Posts: 13459

    Resource leakage generally referrs to memory leakage but can refer to any type of system resource that isn't managed correctly.
    Memory leakage refers to memory that is no longer used but is not freed and therefore is not available for the system to reuse. Java is supposed to remove most of the memory leakage issues of other languages but it is still possible to create situations that waste memory such as java.util.Map that you never remove information from.
    Resource leakage in a more general sence can refer to any system or external application finite resource. The java.awt.Graphics context is supposed to be like this because in java it is a wrapper on a system resource. If you don't close it, it can't be cleaned up by the system. Database resources are another example. Poor Databse code can prevent connections from being recycled by the DBMS and represent a drag on the database.
    I think
    John Lee
    Ranch Hand

    Joined: Aug 05, 2001
    Posts: 2545
    Thanks for the time and effort, Debashish!
    Vivek Raman
    Greenhorn

    Joined: Nov 14, 2005
    Posts: 2
    Regarding the question on Resource Leakage

    4.What is meant by resource leak?
    I don't know.. any rancher would like to try and help?

    David O'Meara has hit the nail on the head. The most common kind of resource leakage that one finds in Java are the DB ones - Connections not getting closed. This is one of the hardest to find and quite irritating : We tend to run out of Connection Pools. Using Weblogic, by monitoring the logs one can find the connection leakages.

    Memory leakages are more common in C/C++ rather than Java (dangling pointers). But in Java it is still possible to have a un-referencable object which would waste space - these are referred to as ISLANDS

    Hope it was useful


    -------------------<br /> SCJP 1.4 SCBCD1.3<br />-------------------
    Stuart Goss
    Ranch Hand

    Joined: Mar 21, 2001
    Posts: 169
    Hi Big!

    Your going to get in trouble with that name ...

    See: JavaRanch naming policy

    By the way, I think unused Strings are not gc'ed either.
    So they use up resources without being retrievable.

    Stuart
    Stuart Ash
    Ranch Hand

    Joined: Oct 07, 2005
    Posts: 637
    Originally posted by Debashish Chakrabarty:
    So it was a question about Marker interfaces afterall.. I remember having read the term "tagging interface" for such interfaces somewhere...Here are few more such interfaces:
  • java.rmi.Remote
  • java.util.EventListener
  • java.lang.Cloneable

  • Thanks to all posts. There is one question (q.4)that's still unanswered..anybody taking a plunge? BTW I am planning to take on this too..I hope to get yr responses there also..
    Regards,

    [ January 31, 2003: Message edited by: Debashish Chakrabarty ]


    Come Java 5, and this role of tagging a trait has been taken up by attributes. What was done earlier in an ad-hoc manner with Marker Interfaces now has a defined way - the J5 attributes.

    Cheers.


    ASCII silly question, Get a silly ANSI.
    Stuart Ash
    Ranch Hand

    Joined: Oct 07, 2005
    Posts: 637
    Oops! I meant annotations.

    Look here
    Abhijeet Thacker
    Greenhorn

    Joined: Jan 15, 2005
    Posts: 16
    "5.What is singleton class?where is it used?
    Singleton is a design pattern meant to provide one and only one instance of an object. Other objects can get a reference to this instance through a static method (class constructor is kept private). Why do we need one? Sometimes it is necessary, and often sufficient, to create a single instance of a given class. This has advantages in memory management, and for Java, in garbage collection. Moreover, restricting the number of instances may be necessary or desirable for technological or business reasons--for example, we may only want a single instance of a pool of database connections."


    I have a small comment over this. there is a minor variation of this design pattern, which is used to restrict the number of instances of a class. It is not limited to be a single instance of a class.


    Always code as if person who is going to maintain your code is a maniac serial killer and knows where you live
    Don Morgan
    Ranch Hand

    Joined: Jul 24, 2003
    Posts: 84
    Regarding singletons and the "one and only one" semantics, your interviewer may probe to see if you know a couple things which can lead to having more than one "singleton" in your system:

    1. multiple classloaders in a single JVM
    2. multiple JVMs (either multiple instances on the same physical box or spread out over a cluster)


    Don Morgan, Founder
    www.DeveloperAdvantage.com - FREE Audiobooks for Software Developers
    Tauri Valor
    Ranch Hand

    Joined: Aug 03, 2005
    Posts: 166
    Resource Leak:
    ================

    Each application on your PC will consume resources as you run them. Small applications might only use one or two percent, while big programs might consume 10 percent or more. Therefore, your resources will drop with each program that you run. Ideally, once you shut a program down again, all the resources used by it will be released back to Windows so that they are available again for later use by other programs. Unfortunately this is not always the case. Sometimes not all resources are being released and Windows still sees them as being used even though they're not, which means it cannot make them available to another application. This is commonly referred to as a resource leak.


    A Moment's insight is sometimes worth a Life's experience.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: here are some interview questions asked?any one kindly reply to these quesitons??