Andriod For Beginner

Interview Question- Java

Question: What is the most important features of JAVA?
Answer: Java is platform independent language.

Question: What is platform independent?
Answer: platform independent means you can run and compile program in one platform and can execute  in any other platform

Question: What all memory areas are allocated by JVM?
Answer: Heap, Stack, Program Counter Register and Native Method Stack.

Question: What is the base class of all classes?
Answer: Java.lang.Object

Question: List two java IDE’s?
Answer:  Eclipse, Net Beans, IntelliJ

Question: How to inherit the constructor?
Answer: No, we can not inherit constructor. And we can call super class constructor from subclass constructor by using super() call.

Question: What is platform?
Answer: A platform is basically the hardware or software environment in which a program runs. There are two type of platform software – based and hardware-based. Java provides Software -based platform.

Question: What is Constructor?
Answer: Constructor is just like a method that is used to initialize the state of an object. It is invoked at the time of object creation

Question: Difference between sleep ad wait in Java?
Answer: Though both are used to pause currently running thread, sleep() is actually meant for short pause because it doesn’t release lock, while wait() is meant for conditional wait and that’s why it release lock which can then be acquired by another thread to change the condition on which it is waiting.

Question: What is the right data type to represent a price in Java?
Answer: BigDecimal if memory is not a concern and Performance is not critical, otherwise double with predefined precision.

Question: How do you convert bytes to String?
Answer: you can convert bytes to the string using string constructor which accepts byte[], just make sure that right character encoding otherwise platform’s default character encoding will be used which may or may not be same.

Question: Which one will take more memory, an int or Integer?
Answer: An Integer object will take more memory an Integer is the an object and it  store meta data overhead about the object and int is primitive type so its takes less space.

Question: Can we use String in the switch case?
Answer: Yes from Java 7 onward we can use String in switch case but it is just syntactic sugar. Internally string hash code is used for the switch. See the detail answer for more explanation and discussion.

Question: What is finalize() method?se?
Answer: It is possible to define a method that will be called just before an object’s final destruction by the garbage collector. This method is called finalize( ), and it can be used to ensure that an object terminates cleanly.

Question: What is an Exception?
Answer: An exception is a problem that arises during the execution of a program. Exceptions are caught by handlers positioned along the thread’s method invocation stack.

Question: Explain Runtime Exceptions?
Answer: It is an exception that occurs that probably could have been avoided by the programmer. As opposed to checked exceptions, runtime exceptions are ignored at the time of compilation.

Question: Define Inheritance?
Answer: It is the process where one object acquires the properties of another. With the use of inheritance the information is made manageable in a hierarchical order.

Question: Define Packages in Java?
Answer: A Package can be defined as a grouping of related types(classes, interfaces, enumerations and annotations ) providing access protection and name space management.

Question: Define JRE i.e. Java Runtime Environment?
Answer: Java Runtime Environment is an implementation of the Java Virtual Machine which executes Java programs. It provides the minimum requirements for executing a Java application.

Question: Difference between Overloading and Overriding?
Answer: Method overloading increases the readability of the program. Method overriding provides the specific implementation of the method that is already provided by its super class parameter must be different in case of overloading, parameter must be same in case of overriding.

Conclusion (Prev Lesson)
(Next Lesson) Interview Questions – Android
Back to Andriod For Beginner
Inquire Now
close slider