- What do you understand by Java?
Java is an object-oriented computer language developed by James Gosling in Sun Microsystem in 1995. It is a secure, fast and reliable language used for many devices, games and applications.
- What do you mean by Object?
An object is a part of core java that consists of methods and classes which describe its state and perform operations. A java program encloses a lot of objects instructing each other their tasks.
- What is class in Java?
Java compresses the codes in several classes which describe new data types. These new data types are used to make objects.
- Define Inheritance.
Java consolidates the component of inheritance which an object-oriented programming concept. Inheritance lets a construed class to gain the techniques for a base class.
- Outline the major Java features.
- Object-Oriented: It is based on object-oriented programming where the class and methods define the state and behavior of object.
- Platform independent: java tackles on “write once and run anywhere” as it supports numerous platforms like Windows, Mac, Sun Solaris, Linux, etc.
- Portable: Program in java gets converted into Java Byte Codes that can be performed on any platform without any dependency.
- Interpreted: Java compiler converts the codes into Java Byte Codes which are then interpreted and executed by Java Interpreter.
- Robust: As there is no pointer allocation, Java has a robust memory management. It has customized garbage collection that denies memory leaks.
- Differentiate between JDK, JRE and JVM.
JVM (Java Virtual Machine): It provides runtime environment for Java Byte Codes to be executed.
JRE (Java Runtime Environment): It includes sets of files required by JVM during runtime.
JDK (Java Development Kit): It consists of JRE along with the development tools essential to write and execute a program.
- Explain method overloading.
Right when a Java program contains more than one procedure with comparable name yet exceptional properties, by then it is called method overloading.
- Compare Overloading and Overriding.
Overloading: It is the case of having two methods of similar name but dissimilar properties.
Overriding: It is the case of having two methods of same name and properties, where one is in child class and other one is in parent class.
- Difference between the Inner Class and Sub Class
Inner Class: It is a class which is settled inside another class. It provides the access rights for the class which is settling it and that can get to all variables and procedures portrayed in the outer class.
Sub Class: It is a class which receives from another class called sub class. It provides access to all public and protected methods and fields of its super class.
- Can we execute any code in JAVA, even before the main method? Explain?
Yes, we can execute any code, even before the main method.
We are using a static square of code in the class while making the objects at stack time of class. Any statements inside this static bit of code will get executed one time while stacking the class, even before the making of objects in the main method.
- Define JSON?
- What are the advantages of JSON over XML?
The advantages of JSON over XML are:
- JSON is Lighter and faster than XML
- Easy to parse and conversion to objects for information consumption
- Better understandable
- Support various data types – JSON support string, array, number, Boolean but XML data are all strings
- Why Java doesn’t use pointers?
Pointers are inclined and slight inattentiveness in their use may result in memory problems and hence Java mainly manages their use.
- What’s the base class of all exception classes?
Java.Lang.throwable – It is the super class of all exception classes and all exception classes are derived from this base class.
- Are there any global variables in Java, which can be accessed by other part of your program?
Global variables are not permitted as it won’t fit well with the possibility of exemplification.
- When threads are not lightweight process in java?
Threads are lightweight process just if threads of same process are executing all the while. Regardless, if threads of different processes are executing all the while then threads are overpowering weight process.
- How can we create a Thread in Java?
There are two ways to create Thread in Java:
- First by implementing Runnable interface and then creating a Thread object from it:
- Second is to extend the Thread Class.
- Define Packages in Java?
A Package can be portrayed as a social occasion of related types (interfaces, classes, checks and remarks) giving access protection and name space management.