Sponsored Links
Ad by Google
In this post, We are going to list down few very basic core java interview questions. The answer of these questions are designed for fresher level only, so we are not going to dig into the deep of the answers. But yes questions are not only for fresher, even though question are listed here can also asked in experience level.
1. What is difference between Java and C++
Here we have listed only few differences.
A class is the blueprint from which individual objects are created, for example You have a blueprint(architecture) for making a two story dream house and that blueprint can also be used by your friends to make their dream house also.
4. Can you write down the syntax of simple Java program? or How to write a Hello World Program in Java?
Here is a simple HelloWorld.java program.
There are four numbers of access specifiers in Java.
The class will compile successfully and at runtime it will gives a message as main method is not public. If you are using IDE most of the IDE will not allows to run without main method so in IDE you can't see the message.
8. What happens, If we remove static modifier from the signature of the main() method?
The class will compile successfully and at runtime it will gives an error as NoSuchMethodError.
9. How to create Object in Java?
Syntax to create object in java
10. Which class is known as parent class of all the classes in Java
Object class is known as parent of all the classes in java, available in java.lang package.
1. What is difference between Java and C++
Here we have listed only few differences.
- Java does not support pointers whereas C++ Support pointers.
- Java does not support destructors, it has automatic garbage collector, whereas C++ supports destructors.
- Java codes run in a JVM(Java Vertual Machine) whereas C++ codes runs on native executable machine.
- Java does not support operator overloading whereas C++ does.
- Java provides built in support for Thread whereas C++ does not provide built in support for Thread.
- JDK(Java Development Kit) includes the JRE, Compilers, JavaDoc, Java Debugger etc. The JDK is required to create and compile java programs if you want to develop java programs/applications than you need JDK to be installed in your machine.
- JRE(Java Runtime Environment) includes libraries, Java Virtual Machine and other components to run Java programs/application and applets. If your concern is just to run java application then you don't need to installed JDK you just need to install JRE only.
A class is the blueprint from which individual objects are created, for example You have a blueprint(architecture) for making a two story dream house and that blueprint can also be used by your friends to make their dream house also.
4. Can you write down the syntax of simple Java program? or How to write a Hello World Program in Java?
Here is a simple HelloWorld.java program.
public class HelloWorld { public static void main(String...args) { System.out.println("Hello World !!!"); } }5. What are the access modifiers in Java can you list down?
There are four numbers of access specifiers in Java.
- default (no specifier)
- private
- protected
- public
- public access modifier, mean that class is visible to all classes everywhere. Top level of accessibility is provided by using public modifier.
- If a member is declared with protected modifier, mean that class can be accessed within its own package and, in addition, by subclass of its class in another package.
- If a member is declared with private modifier, mean that member can only be accessed in its own class.
The class will compile successfully and at runtime it will gives a message as main method is not public. If you are using IDE most of the IDE will not allows to run without main method so in IDE you can't see the message.
8. What happens, If we remove static modifier from the signature of the main() method?
The class will compile successfully and at runtime it will gives an error as NoSuchMethodError.
9. How to create Object in Java?
Syntax to create object in java
HelloWorld hello = new HelloWorld();You can read more from here How many ways to create object in java
10. Which class is known as parent class of all the classes in Java
Object class is known as parent of all the classes in java, available in java.lang package.
Sponsored Links
0 comments:
Post a Comment