Important Core Java Interview questions for Fresherby Mayank K. mayankseo
1.Explain super keyword in java.
The “super” keyword in java is basically related to the parent class. A super keyword can be used for several reasons such as-
It can be used to call the superclass or the parent class constructor.
It can also be used to access the method of the superclass which has been hidden by a subclass.
A super keyword can also be used to call the constructor of the parent class.
2. Compare java and python.
Java and Python, both the languages hold an important place in today’s IT industry. But in some factors, one is better than the other. Such factors are:
Java is easy to use, whereas Python is very good in this case.
The speed of coding in Java is average, whereas in Python it is excellent.
In Java, the data types are statically typed, whereas in python the data types are dynamically typed.
Java is average in the case of data sciences and machine learning applications, whereas data science and machine learning applications are majorly based on python. Python is very good in this case.
3. What are the main differences between the Java platform and other platforms?
There are the following differences between the Java platform and other platforms.
Java is the software-based platform whereas other platforms may be the hardware platforms or software-based platforms.
Java is executed on the top of other hardware platforms whereas other platforms can only have the hardware components.
4. Explain public static void main(String args).
Public: Public is an access modifier, which is used to specify who can access this method. Public means that this Method will be accessible by any Class.
Static: It is a keyword in java which identifies it is class-based i.e it can be accessed without creating the instance of a Class.
Void: It is the return type of the method. Void defines the method which will not return any value.
Main: It is the name of the method which is searched by JVM as a starting point for an application with a particular signature only. It is the method where the main execution occurs.
String args : It is the parameter passed to the main method.
5. List the features of Java Programming language.
There are the following features in Java Programming Language.
- Platform Independent:
- Architecture Neutral:
- High Performance:
Java is easy to learn. The syntax of Java is based on C++ which makes easier to write the program in it.
Java follows the object-oriented paradigm which allows us to maintain our code as the combination of different type of objects that incorporates both data and behavior.
Java supports read-once-write-anywhere approach. We can execute the Java program on every machine. Java program (.java) is converted to bytecode (.class) which can be easily run on every machine.
Java is a platform independent programming language. It is different from other programming languages like C and C++ which needs a platform to be executed. Java comes with its platform on which its code is executed. Java doesn't depend upon the operating system to be executed.
Java is secured because it doesn't use explicit pointers. Java also provides the concept of ByteCode and Exception handling which makes it more secured.
Java is a strong programming language as it uses strong memory management. The concepts like Automatic garbage collection, Exception handling, etc. make it more robust.
Java is architectural neutral as it is not dependent on the architecture. In C, the size of data types may vary according to the architecture (32 bit or 64 bit) which doesn't exist in Java.
Java uses the Just-in-time (JIT) interpreter along with the compiler for the program execution.
Java is faster than other traditional interpreted programming languages because Java bytecode is "close" to native code. It is still a little bit slower than a compiled language (e.g., C++).
We can write Java programs that deal with many tasks at once by defining multiple threads. The main advantage of multi-threading is that it doesn't occupy memory for each thread. It shares a common memory area. Threads are important for multi-media, Web applications, etc.
Java is distributed because it facilitates users to create distributed applications in Java. RMI and EJB are used for creating distri buted applications. This feature of Java makes us able to access files by calling the methods from any machine on the internet.
Java is a dynamic language. It supports dynamic loading of classes. It means classes are loaded on demand. It also supports functions from its native languages, i.e., C and C++.
6. Why is Inheritance used in Java?
There are various advantages of using inheritance in Java that is given below.
Inheritance provides code reusability. The derived class does not need to redefine the method of base class unless it needs to provide the specific implementation of the method.
Runtime polymorphism cannot be achieved without using inheritance.
We can simulate the inheritance of classes with the real-time objects which makes OOPs more realistic.
Inheritance provides data hiding. The base class can hide some data from the derived class by making it private.
Method overriding cannot be achieved without inheritance. By method overriding, we can give a specific implementation of some basic method contained by the base class.
7. What is the difference between JDK, JRE, and JVM?
JVM is an acronym for Java Virtual Machine; it is an abstract machine which provides the runtime environment in which Java bytecode can be executed. It is a specification which specifies the working of Java Virtual Machine. Its implementation has been provided by Oracle and other companies. Its implementation is known as JRE.
JVMs are available for many hardware and software platforms (so JVM is platform dependent). It is a runtime instance which is created when we run the Java class. There are three notions of the JVM: specification, implementation, and instance.
JRE stands for Java Runtime Environment. It is the implementation of JVM. The Java Runtime Environment is a set of software tools which are used for developing Java applications. It is used to provide the runtime environment. It is the implementation of JVM. It physically exists. It contains a set of libraries + other files that JVM uses at runtime.
JDK is an acronym for Java Development Kit. It is a software development environment which is used to develop Java applications and applets. It physically exists. It contains JRE + development tools. JDK is an implementation of any one of the below given Java Platforms released JDK by Oracle Corporation:
- Standard Edition Java Platform
- Enterprise Edition Java Platform
- Micro Edition Java Platform
Created on Dec 6th 2018 07:47. Viewed 344 times.