This website includes Education Information like a programming language, job interview question, general knowledge.mathematics

Education log

PageNavi Results No.

Ads

Wednesday, October 23, 2019

java programming interview questions and answers for experienced

java programming interview questions and answers for experienced


In this Article learn java programming interview questions and answers for experienced. java is programming language.there are two java programming one is core java and the second is advanced java programming so without time weast learn java programming interview questions and answers for experienced.




11.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.



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 in their jobs. This concept is a part of core java.


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.


2. Can we declare the main method of our class as private?:

Answer :

In java, main method must be public static in order to run any application correctly. If


Answer :

In java, main method must be public static in order to run any application correctly. If

main the method is declared as private, the developer won't get any compilation error however, it will
not get executed and will give a runtime error.

23.  Can we declare a class as Abstract without having any abstract method?


Yes, we can create an abstract class by using an abstract keyword before class name even if it doesn't have any abstract method. However, if a class has even one abstract method, it must be declared as abstract otherwise it will give an error.



Yes, we can create an abstract class by using an abstract keyword before class name even if it doesn't have any abstract method. However, if a class has even one abstract method, it must be declared as abstract otherwise it will give an error.

3.     Can we declare the main method of our class as private?


In java, main method must be public static in order to run any application correctly. If main method is declared as private, the developer won't get any compilation error however, it will not get executed and will give a runtime error.


44.   Differentiate between JDK, JRE, and JVM


JVM :

Stands for Java Virtual Machine which provides a 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.



JVM :

Stands for Java Virtual Machine which provides a 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.


5. Explain public static void main(String args[]).:


Answer :


public :
Public is an access modifier, which is used to specify who can access this method.



Answer :


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
It is a keyword in java which identifies it is class-based i.e it
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.


6. How can we pass an argument to a function by reference instead of pass by value?:


Answer :


n java, we can pass an argument to a function only by value and not by reference.



Answer :


n java, we can pass an argument to a function only by value and not by reference.


7. What is an Infinite Loop? How infinite loop is declared?


An infinite loop runs without any condition and runs infinitely. An infinite loop can be broken by defining any breaking logic in the body of the statement blocks.



An infinite loop runs without any condition and runs infinitely. An infinite loop can be broken by defining any breaking logic in the body of the statement blocks.

for (;;)
{
    // Statements to execute

    // Add any loop breaking logic
}


8. Is String a data type in java?


The string is not a primitive data type in java. When a string is created in java, it's actually an object of Java.Lang.String class that gets created. After the creation of this string object, all built-in methods of String class can be used on the string object.



The string is not a primitive data type in java. When a string is created in java, it's actually an object of Java.Lang.String class that gets created. After the creation of this string object, all built-in methods of String class can be used on the string object.


9. What are constructors in Java?:


Answer :


In Java, constructor refers to a block of code which is used to initialize an object.



Answer :


In Java, constructor refers to a block of code which is used to initialize an object.

It must have the same name as that of the class. Also, it has no return type and it is automatically called when an object is created.
There are two types of constructors: 1.Default constructor 2.Parameterized constructor


10. What is the difference between an Inner Class and a Sub-Class? :

Answer :


An Inner class is a class that is nested within another class.


Answer :


An Inner class is a class that is nested within another class.

An The inner class has access rights for the class which is nesting it
and it can access all variables and methods defined in the outer class.
and it can access all variables and methods defined in the outer class.
Sub-class can access all public and protected methods and fields of its superclass.


11. What are Java Packages? What's the significance of packages?:


Answer :


In Java, package is a collection of classes and interfaces which are bundled together as



Answer :


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.

12. What is the Final Keyword in Java? Give an example.:


Answer :


In java, a constant is declared using the keyword Final. Value can be assigned



Answer :


In java, a constant is declared using the keyword Final. Value can be assigned

only once and after the assignment, the value of a constant can't be changed.
n below example, a constant with the name const_val is declared and assigned value:
Private Final int const_val=100
When a method is declared as final, it can NOT be overridden by the subclasses. This method
are faster than any other method, because they are resolved at the complied time.
When a class is declared as final,it cannot be subclassed. Example String, Integer and other wrapper classes.


13. What is the Final Keyword in Java?


In java, a constant is declared using the keyword Final. Value can be assigned only once and after assignment, value of a constant can't be changed.

In below example, a constant with the name const_val is declared and assigned value:

Private Final int const_val=100



In java, a constant is declared using the keyword Final. Value can be assigned only once and after assignment, value of a constant can't be changed.

In below example, a constant with the name const_val is declared and assigned value:

Private Final int const_val=100


14. What is the ternary operator? Give an example.:


Answer :


Ternary operator, also called conditional operator is used to decide which value to



Answer :


Ternary operator, also called conditional operator is used to decide which value to

assign to a variable based on a Boolean value evaluation. It's denoted as?
In the below example, if rank is 1, status is assigned a value of "Done" else "Pending".

public class conditions {
    public static void main(String args[]) {
        String status;
        int rank = 3;
        status = (rank == 1) ? "Done" : "Pending";
        System.out.println(status);
    }
}


15. What is the difference between Array list and vector?:


Answer :



Answer :


Array List
Vector
Array List is not synchronized.
Vector is synchronized.
Array List is fast as it’s non-synchronized.
Vector is slow as it is thread safe.
If an element is inserted into the Array List, 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.



16. Why Java is platform-independent?:


Answer :


Platform independent practically means “write once run anywhere”. Java is called so



Answer :


Platform independent practically means “write once run anywhere”. Java is called so

because of its byte codes which can run on any system irrespective of its underlying operating system.


No comments:

Post a Comment