• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

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

 
Ranch Hand
Posts: 184
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe you should do your own homework.
 
Ranch Hand
Posts: 250
Python Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
     
    author
    Posts: 14112
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    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.
     
    Ranch Hand
    Posts: 1936
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    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.
     
    Bartender
    Posts: 4179
    22
    IntelliJ IDE Python Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    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?
     
    Ranch Hand
    Posts: 1140
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    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
    Posts: 250
    Python Spring Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    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 ]
     
    Rancher
    Posts: 13459
    Android Eclipse IDE Ubuntu
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    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
     
    Ranch Hand
    Posts: 2545
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thanks for the time and effort, Debashish!
     
    Greenhorn
    Posts: 2
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    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
     
    Ranch Hand
    Posts: 169
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    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
     
    Ranch Hand
    Posts: 637
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    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.
     
    Stuart Ash
    Ranch Hand
    Posts: 637
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Oops! I meant annotations.

    Look here
     
    Greenhorn
    Posts: 16
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    "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.
     
    Ranch Hand
    Posts: 84
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    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)
     
    Ranch Hand
    Posts: 181
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    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.
     
    Maybe he went home and went to bed. And took this tiny ad with him:
    Smokeless wood heat with a rocket mass heater
    https://woodheat.net
    reply
      Bookmark Topic Watch Topic
    • New Topic