Java and correct answer

If you know that a long field is accessed by more than one thread e. I am not posting an answer to this question as I like you to do some research, practice and spend some time to understand this confusing principle well.

It also contains questions from GOF design patterns. Any modification will result in a new object e. Most common example is an Object which contain the reference of java.

I am sure you have seen many of these questions personally on your interviews and many of you would have answered them correctly as well. For example, String class overrides this equals method so that you can compare two Strings, which are the different object but contains same letters.

Which means the size of primitive int is same in both bit and bit Java virtual machine.

Why should you use it? Yes, we can cast but int is 32 bit long in java while byte is 8 bit long in java so when you cast an int to byte higher 24 bits are lost and a byte can only hold a value from to In some cases volatile also provide atomicity e. Please see the answer for step by step guide to creating Immutable class in Java.

You can use memory related methods from java. Ideally you should avoid IO in critical path of your application. Take a look at the "how jchq helped me" forum at http: If you make a variable final it means its value cannot be changed once initialized.

Java Program to find Armstrong numbers with Example

Particularly with thread, you should: Though be careful while using thread local variable in manged environment e. Here are few advantages of using PreparedStatement in Java: How do you create an Immutable object in Java?

Any thread local variable which is not removed once its work is done can potentially cause a memory leak in Java application. Serializable interface is used to make Java classes serializable so that they can be transferred over network or their state can be saved on disk, but it leverages default serialization built-in JVM, which is expensive, fragile and not secure.

DateFormat class allows you to format date on many popular formats.Mar 02,  · Important Topics for Java Interviews Apart from quantity, as you can see with a huge number of questions, I have worked hard to maintain quality as well.

Using commons has a couple of advantages in my particular scenario: it comes with a decent level of a guarantee that it will work and is tested; it's self documenting, unlike a regex which I would extract into a static helper method anyway; it's a university project, so.

I recently changed my path so I could follow along in the Head First Java book and I had Eclipse before. Now when I try to get onto Eclipse again it won't open because it says it can't find a JRE o.

PreparedStatement and CallableStatement for executing queries.

Out of these three, Statement is used for general purpose queries, PreparedStatement is used for executing parametric query and CallableStatement is used for executing Stored Procedures.

PreparedStatement is also a popular topic in java interviews. Questions like Difference between Statement and PreparedStatement in Java and.

Question 4) A byte can be of what size.

1) to 2) (-2 power 8)-1 to 2 power 8 3) to 4)depends on the particular implementation of the Java Virtual machine. Armstrong number Example in Java How to check if a number is Armstrong number or not?

or write a Java program to find Armstrong number?This is a common Java interview question asked on campus interviews and fresher level interviews.

Java and correct answer
Rated 0/5 based on 21 review