studentsjungle@gmail.com

+91 7871727977

Students Jungle - Jobs, Events, News, Colleges, Schools
MENU
Home
Jobs
College Jobs School Jobs Government Jobs
Events
Conferences Symposiums
Colleges
Engineering Colleges Arts and Science Colleges
Posts Materials
Interview Questions
Programming General Marketing

Java Interview Questions

What do you understand by Java?
     Java is an object-oriented computer language.
    It is a high-level programming language developed by James Gosling in Sun Microsystem in 1995.
    Java is a fast, secure and reliable language used for many games, devices and applications.

Compare Java & Python
Criteria Java Python
Ease of use Good Very Good
Speed of coding Average Excellent
Data types Static typed Dynamically typed
Data Science & machine learning applications average very good
Outline the major Java features
Object-Oriented – java is based on object-oriented programming where the class and methods describe about the state and behavior of object.
Portable – Java program gets converted into Java Byte Codes that can be executed on any platform without any dependency.
Platform independent – java works on “write once and run anywhere” as it supports multiple platforms like Windows, Linux, Mac, Sun Solaris, etc.
Robust – Java has a strong memory management as there is no pointer allocations. It has automatic garbage collection that prohibits memory leaks.
Interpreted – java compiler converts the codes into Java Byte Codes which are then interpreted and executed by Java Interpreter.

What do you mean by Object?
An object consists of methods and class which depict its state and perform operations. A java program contains a lot of objects instructing each other their jobs. This concept is a part of core java.
What is class in Java?
Java encapsulates the codes in various classes which define new data types. These new data types are used to create objects.
Differentiate between JDK, JRE and JVM.
JVM stands for Java Virtual Machine which provides runtime environment for Java Byte Codes to be executed.
JRE (Java Runtime Environment) that includes sets of files required by JVM during runtime.
JDK (Java Development Kit) consists of JRE along with the development tools required to write and execute a program.

Define Inheritance.
Java includes the feature of inheritance which an object-oriented programming concept. Inheritance lets a derived class to inherit the methods of a base class.
Explain method overloading.
When a Java program contains more than one methods with the same name but different properties, then it is called method overloading.
Compare Overloading and Overriding.
Overloading refers to the case of having two methods of same name but different properties, but overriding occurs when there are two methods of same name and properties, but one is in child class and one is in parent class.
Explain the creation of a thread-safe singleton in Java using double-checks locking
Singleton is created with double checked locking as before Java 5 acts as an broker and it’s been possible to have multiple instances of Singleton when multiple threads creates an instance of Singleton at the same time. Java 5 made it easy to create thread-safe Singleton using Enum. Using a volatile variable is essential for the same.
Differentiate between StringBuffer and StringBuilder in Java programming.
String Buffer String Builder
StringBuffer methods are synchronized StringBuilder is non synchronized
Storage area is Heap and modified easily. Storage is Heap and can be modified.
StringBuffer is thread safe. StringBuilder is fast as it is not thread safe
Performance is very slow Performance is very fast.
Difference between Array list And Vector.
Array List Vector
Array List is not synchronized. Vector is synchronized.
Array List is fast Vector is slow
it increases its Array size by 50%. Vector defaults to doubling size of its array.
Array List does not define the increment size. Vector defines the increment size.
Array List can only use Iterator for traversing an Array List. Except Hashtable, Vector is the only other class which uses both Enumeration and Iterator.
Difference between the Inner Class and Sub Class.
It’s a class which is nested within another class.     It’s a class which inherits from another class called super class.
Inner class provides the access rights for the class which is nesting it and that can access all variables and methods defined in the outer class.     Sub-class provides access to all public and protected methods and fields of its super class.
Can we execute any code, even before the main method? Explain?
Yes, We can execute any code, even before the main method. We are using a static block of code in the class when creating the objects at load time of class. Any statements within this static block of code will get executed one time while loading the class, even before the creation of objects in the main method.
How can we restrict inheritance for a class?
We can restrict inheritance for class by following steps.
 By using final keyword
   If we make all method final, then we cannot override that.
   By using private constructors
   By using Javadoc comment (//)
Java doesn't support multiple inheritance. Why?
Java doesn’t support multiple inheritance. Because we cannot use different methods in one class it creates an ambiguity.
Example:

class Intellipaat1
{
void test()
{
system.out.println("test() method");
}
}class Intellipaat2
{
void test()
{
system.out.println("test() method");
}
}Multiple inheritance
class C extends Intellipaat1, Intellipaat2
{
………………………………………….
…………………………………………..
}

Intellipaat1 and Intellipaat2 test() methods are inheriting to class C
So which test() method C class will take. As Intellipaat1 & Intellipaat2 class test () methods are different, So here we would face ambiguity.

Are constructors inherited? Can a subclass call the parent's class constructor?
We cannot inherit a constructor. We create an instance of a subclass using a constructor of one of its superclass. Because override the superclass constructor is not our wish so that, we override a superclass constructor, then we destroy the encapsulation abilities of the language.
New Mobile App for Jobs in Colleges

New Mobile App for Jobs in Schools

Latest News

SSLC(10th) Study Material

HSC(12th) Study Material

Tags Cloud

Jobs Jobs in Colleges Jobs in Schools Government Jobs Conferences Symposiums International Confrences Materials Educational News Interview Questions
Terms of use Privacy policy Advertise with us About Us Contact us

Copyright © SJ :: Students Jungle. All Rights Reserved

Developed By SMS :: SOFT MaX SOLUTIONS