Q1. How much memory space does a primitive type int occupy in Java? A1. 4 bytes. Q2. Java objects get stored in the heap memory space, but how about the primitive variables? A2. It depends. 1) Primitives defined locally would be on the stack.
public class Primitive
public static void main(String args)
int number = 1; // This is on the stack.
2) If a primitive is…...
What is UTC? which stands for Coordinated Universal Time. The diagram below shows the standard time offsets of different countries. Some places observe daylight saving time (DST) during their respective summer periods. For example, Los Angeles (i.e LA) UTC – 8.0 hours (without DST) & UTC – 7.0 hours (with…
Read more ›
Q1. What do you understand by the terms “autoboxing” and “autounboxing” in Java? A1. Java automatically converts a primitive type like “int” into corresponding wrapper object class Integer. This is known as the autoboxing. When it converts a wrapper object class Integer back to its primitive type “int”, it is…...
Q. What is the difference between java.sql.Date and java.util.Date? A. java.util.Date supports both date and time. java.sql.Date supports only date, java.sql.Time supports only time, and java.sql.TimeStamp supports both date and time. Q. Why should you favor using the joda-time library for date time operations? A. The Java Date and Calendar…...
Q1. What will be the output of the following code snippet?
String s = " Hello ";
s += " World ";
A1. The output will be
with the leading and trailing spaces. Some would expect a trimmed “Hello World”. So, what concepts does this question try to test? String objects are immutable and there is a trick in…...