Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understanding basic Java-specific interverview questions

Tags:

java

Last day I faced an interview and they asked me java questions among which for some questions I didn't know the answer. I am curious to know the answer for that question. Interviewer did not tell me the answer. I am asking that questions here:

  • Does Java provide any construct to find out the size of an object?
  • Give a simplest way to find out the time a method takes for execution without using any profiling tool?
  • What are checked exceptions and runtime exceptions?
  • If I write return at the end of the try block, will the finally block still execute?
  • If I write System.exit (0); at the end of the try block, will the finally block still execute?

Want to know answers of above question so that it can help me next time.

Explanations, notes, and/or relevant links to the specification would be greatly appreciated over just the simple answers -- and what is a good way to learn this stuff?

like image 879
Harry Joy Avatar asked Mar 05 '11 17:03

Harry Joy


People also ask

What are the main basics of Java?

Simple: Java is a simple language because its syntax is simple, clean, and easy to understand. Complex and ambiguous concepts of C++ are either eliminated or re-implemented in Java. For example, pointer and operator overloading are not used in Java. Object-Oriented: In Java, everything is in the form of the object.

What is Java short answer?

Java is the high-level, object-oriented, robust, secure programming language, platform-independent, high performance, Multithreaded, and portable programming language. It was developed by James Gosling in June 1991. It can also be known as the platform as it provides its own JRE and API.


1 Answers

I think that all of these can be answered by searching for existing Stack Overflow questions. The reason I think it's worth answering this question with links to previous answers is that you've asked about a lot of different issues, each one of which is interesting in its own right. It's not so likely you'll get an in-depth discussion of these when asking about them all together, but in the answers and comments on previous questions here you'll find a lot of detail and discussion which (a) may be interesting and (b) may help in further interviews. (There may well be better choices - these are just the first reasonable SO answers I found.)

Does Java provide any construct to find out the size of an object?

  • In Java, what is the best way to determine the size of an object?
  • sizeof java object

Give a simplest way to find out the time a method takes for execution without using any profiling tool?

  • How do I time a method's execution in Java?

What are checked exceptions and runtime exceptions?

  • Differences between Runtime/Checked/Unchecked/Error/Exception

If I write return at the end of the try block, will the finally block still execute?

  • Does finally always execute in Java?

If I write System.exit (0); at the end of the try block, will the finally block still execute?

  • How does Java's System.exit() work with try/catch/finally blocks?
like image 176
Mark Longair Avatar answered Nov 02 '22 16:11

Mark Longair