Call us: +91-9962812914  |  +91-9962812876 |


What is java

Java is an object oriented programming language.
Java programs are platform independent.
Java is designed to be easy to learn
Java code that runs on one platform does not need to be recompiled to run on another platform.
Java is used to create server-side web applications.
Java is considered to be more dynamic.

1.What are the various access specifiers for java classes?

In java,access specifiers are the keywords used before a class name which defined the access scope.
The types of access specifiers are
Public-Class,Method,Field is accessible from anywhere.
Protected-Method,Field,class can be accessed from the same class to which they belong or from the sub-classes, and from the class of same package,but not from outside.
Default:Method.Field,Class can be accessed only from the same package and not from outside of its native package.
Private:Method.Field can be accessed from the same class to which they belong.

2.Why java called platform independent?

Java is called as a platform independent programming language as it works on the principle “compile once,run everywhere”.If you have some code in java and you have compiled that,you execute the same code on any platform,the only thing you need to corresponding JVM(Java Virtual Machine).

3.What is meant by final keyword in java?

If final variable is used in front of variable,we cant change the value.
If the variable is used in front of method,it cant be overridden.
If it is used in front of class,class cant be extended by any other class.

4.What is the difference between overloading and overriding in java?

Method signature should not be same
It happens at time of code compilation,so it called compile time polymorphism.
Method can have any return type
Method can have any access level.

Method signature should be same.
It happens on time of runtime,so it is called as runtime polymorphism.
Method return type must be as same as super class method.
Method must have same or wide access level than super class method access level.

5.what is a pointer and does Java support pointers?

Pointer is a reference handle to a memory location,improper handling of pointers leads to memory leaks and reliability issues hence java doesn’t support the usage of pointers.

6.what is the difference between while and do while statement?

A while statement checks at the beginning of a loop to see whether the next loop iteration should occur.A do while statement checks at the end of a loop to see whether the next iteration of a loop should occur.The do while statement will always the execute the body of a loop at least once.

7.What is java applet?

Applet is a java program.
It has been designed for transmitting the java code over the internet.
It is automatically executed by java-enabled web browser.
Applet can respond to the user input.
Applet is dynamically programmed.

8.What are loops in java?What are the three types of loops?

Looping is used in programming to execute a statement or a block of statement repeatedly.
There are three types of loops in java

For loops
For loops are used in java to execute statements repeatedly for a given number of times.For loops are used when number of times to execute the statements is known to programmer.

While loops
While loop is used when certain statements need to be executed repeatedly until a condition is fulfilled.In while loops, condition is checked first before execution of statements.

Do While Loop

Do while loop is same as While loop with only difference that condition is checked after execution of block of statements.Hence in case of do while loop,statements are executed at least once.

9.What are java packages?What is the significance of packages?

In java,package is a collection of classes and interfaces which are bundled together as they are related to each other. Use of packages helps developers to modularize the code and group the code for proper re-use.Once code has been packaged in packages,it can be imported in other classes and used.

10.How we can execute any code even before main method?

If we want to execute any statements before even creation of objects at load time of class, we can use a static block of code in the class.Any statements inside this static block of code will get executed once at the time of loading the class even before creation of objects in the main method.

Leave a comment

Your email address will not be published. Required fields are marked *