Search Interview Questions | More than 3000 questions in repository. There are more than 900 unanswered questions. Click here and help us by providing the answer. Have a video suggestion. Click Correct / Improve and please let us know. |
|
| ||||
Interview Questions and Answers - Order By Rating | ||||
| ||||
Ans. The Permanent Generation (PermGen) space has completely been removed and is kind of replaced by a new space called Metaspace. The consequences of the PermGen removal is that obviously the PermSize and MaxPermSize JVM arguments are ignored and you will never get a java.lang.OutOfMemoryError: PermGen error. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   jvm   memory management   permgen   permanent generation   metaspace   advanced   architecture expert | ||||
| ||||
Ans. Yes, We can call garbage collector directly but it doesn't guarantees that the gc will start executing immediately. This gc( ) method appears in both Runtime and System classes of java.lang package. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   garbage collection   java memory management   jvm   gc   yes no Asked in 4 Companies expert | ||||
Try 1 Question(s) Test | ||||
| ||||
Ans. Java is a portable-language because without any modification we can use Java byte-code in any platform(which supports Java). So this byte-code is portable and we can use in any other major platforms. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   bytecode   jvm   compiler   portable   features of java   basic interview question | ||||
| ||||
Ans. You can find JVM - 32 bit or 64 bit by using System.getProperty() from Java program. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   jvm 32   jvm 64   jvm | ||||
| ||||
Ans. Java runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX/Linux like HP-Unix, Sun Solaris, Redhat Linux, Ubuntu, CentOS, etc | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   jvm   platforms | ||||
| ||||
Ans. Java uses Just-In-Time compiler to enable high performance. Just-In-Time compiler is a program that turns Java bytecode into instructions that can be sent directly to the processor. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   compiler   jvm   bytecode   justintime compiler   architecture | ||||
| ||||
Ans. CLASSPATH and PATH are the two variables. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   classpath   path   environment variables   jvm | ||||
| ||||
Ans. At the beginning of an object's life, the Java virtual machine (JVM) allocates memory on the heap to accommodate the object's instance variables. When that memory is first allocated, however, the data it contains is unpredictable. If the memory were used as is, the behavior of the object would also be unpredictable. To guard against such a scenario, Java makes certain that memory is initialized, at least to predictable default values before it is used by any code. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   constructor   oops   default constructor   jvm expert | ||||
Try 2 Question(s) Test | ||||
| ||||
Ans. There are total six ways 1. literals When we create a String using double quotes, JVM looks in the String pool to find if any other String is stored with same value. If found, it just returns the reference to that String object else it creates a new String object with given value and stores it in the String pool. 2. new keyword When we use new operator, JVM creates the String object but dont store it into the String Pool. We can use intern() method to store the String object into String pool or return the reference if there is already a String with equal value present in the pool. 3. string buffer 4. string builder 5. System.out.println 6. char to string | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   string class   string   jvm   memory management   string pool Asked in 5 Companies basic   frequent | ||||
Try 3 Question(s) Test | ||||
| ||||
Ans. substring method would build a new String object keeping a reference to the whole char array, to avoid copying it. Hence you can inadvertently keep a reference to a very big character array with just a one character string. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   string class   string   substring   memory leaks   jvm   memory management   advanced   architecture   technical architect   technical lead expert | ||||
| ||||
Ans. Java bytecode is the instruction set of the Java virtual machine. Each bytecode is composed by one, or two bytes that represent the instruction, along with zero or more bytes for passing parameters. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   jvm   interpreter   platform independent Asked in 1 Companies | ||||
| ||||
Ans. Yes and No. JVM is an extra layer that translates Byte Code into Machine Code. So Comparing to languages like C, Java provides an additional layer of translating the Source Code. C++ Compiler - Source Code --> Machine Code Java Compiler - Source Code --> Byte Code , JVM - Byte Code --> Machine Code Though it looks like an overhead but this additional translation allows Java to run Apps on all platforms as JVM provides the translation to the Machine code as per the underlying Operating System. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   jvm   interpreter   platform independent   yes-no   advanced   architecture | ||||
| ||||
Ans. Bytecode is a highly optimized set of instructions designed to be executed by the Java run-time system. Its called Byte Code because each instruction is of 1-2 bytes. Sample instructions in Byte Code - 1: istore_1 2: iload_1 3: sipush 1000 6: if_icmpge 44 9: iconst_2 10: istore_2 | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   jvm   interpreter   platform independent   byte code | ||||
| ||||
Ans. PATH is the variable that holds the directories for the OS to look for executables. CLASSPATH is the variable that holds the directories for JVM to look for .class files ( Byte Code ). | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   path   classpath   byte code   jvm   basic interview question Asked in 3 Companies intermediate   rare | ||||
| ||||
Ans. No, Java runs on a virtual machine called JVM and hence doesn't embed well with the underlying hardware. Though we can create a platform independent system software but that would be really slow and that's what we would never need. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   system software java   jvm   yes-no   yes no   java operating system   architecture | ||||
| ||||
Ans. OutOfMemoryError in Java is a subclass of VirtualMachineError and is thrown by JVM when it runs out of heap memory. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  outofmemoryerror   error   exceptions   jvm   java   heap memory   heap | ||||
Ans. JVM reads Source Code and generates Byte Code. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   jvm | ||||