Thursday, 21 March 2019

Best 35 Java Interview Questions and Answers 2019

1.Explain about Object Oriented Programming Language

Object-Oriented Programming is a methodology or paradigm to design a program using classes and objects. It simplifies the software development and maintenance.

2.Does Constructor Return any Value?

when you call the constructor using a new keyword you get an object. Though it doesn’t explicitly return something but instead it creates or constructs something which you can use as an instance of a class. yes, it is the current class instance. (We cannot use return type yet it returns a value).

3.Can we Overload main() method?

yes we can overload main method. main method must not be static main method. Yes, main method can be overloaded.

4.What is Marker Interface?

A marker interface in Java is an interface with no fields or methods. Put more simply, an empty interface in Java is called a marker interface. Examples: Serializable , Cloneable and Remote interfaces.

5.Can an Interface be Final?

An interface is a pure abstract class. Hence, all methods in an interface are abtract, and must be implemented in the child classes. So, by extension, none of them can be declared as final

6.What is Exception Handling?

An unexpected event that disturbs the normal flow of program.

7.What are the two types of Exceptions in Java ?

  1. checked Exception
  2. Unchecked Exception

8.What is Multithreading?

Multithreading in java is a process of executing multiple threads simultaneously. A thread is a lightweight sub-process, the smallest unit of processing. Multiprocessing and multithreading, both are used to achieve multitasking.

9.What are the Basic Interfaces of Java Collections Framework

Java Collection means a single unit of objects. Java Collection framework provides many interfaces (Set, List, Queue, Deque) and classes (Array List, Vector, Linked List, Priority Queue, HashSet, Linked HashSet, TreeSet).

10.What are the JDBC API Components?

The JDBC API. The JDBC API gives access of programming data from the Java. JDBC Driver Manager. The JDBC Driver Manager is the class in JDBC API. JDBC Test Suite. JDBC-ODBC Bridge.

11.What are the Steps to Connect to the Database in Java?

  • Step 1: Register the Driver class
  • Step 2: Create connection
  • Step 3: Create statement
  • Step 4: Execute queries
  • Step 5: Close connection

12.What are the JDBC Statements?

Statement:
It can be used for general-purpose access to the database. It is useful when you are using static SQL statements at Run time.
Prepared Statement:
It can be used when you plan to use the same SQL statement many times. The Prepared Statement interface accepts input parameters at Run time.
Callable Statement:
Callable Statement can be used when you want to access database stored procedures.

13.Super Class of Java

The super keyword in Java is a reference variable which is used to refer immediate parent class object.

14.Does Java Support Multiple Inheritance

No..Java Does not Support Multiple in hesitance. Once string object is created its data or state can’t be changed but a new string object is created.

15.Why String is Immutable Object?

In Java, string objects are immutable. Immutable simply means unmodifiable or unchangeable.

16.Nested For loops

Class For
{
public static void main(String [] args)
{
for(int i=0;i<5;i++)
{
for(int j=0;j<=i;j++)
{
System.out.print(“*”);
}
System.out.Println();
}
}
}

17.Basic Inheritance Program

Class A
{
public void add()
{
System.out.println(“hi”);
}
class B extends A
{
public static void main(String [] args)
{
A ob=new A();
ob.add();
}
}

18.What is gc?

UN Reachable objects in program automatically eligible for garbage collection.

19.What is the difference between HashSet and TreeSet

TreeSet : tree set is faster performance compare to hashset. HashSet : hash set not maintain insertion order.but tree set maintain ascending order of elements.

20.What is the difference between Collection and Collections?

Collection is a interface and Collections is a class. both are contains in util package.

21.What is the life-cycle of a servlet?

  • Init
  • Service
  • Destroy

22.What is JSP?

Java server page used for front end development. method overloading programm and methos overriding and differences

23.What is over loading and over riding

Overloading: same method but differnt parameters.
Overriding: same method name in different class.

24.What is Abstraction and Encapsulation

Abstraction:hiding internal implementation.
Encapsulation:wrapping of data in single unit.

25.What is Array?

Collection of homogenous datatypes.

26.How to reverse string without using reverse method

String s=”java”
for(int i=s.length()-1;i>=0;i++)
{
System.out.print(CharAt(i));
}

27.Features of java

  • platform indepdent
  • object oriented
  • high performance
  • secured

28.Write a query how Delete Rows from mysql

delete from table(name) where (row)=;

29.Difference between Truncate, Delete, Drop

Truncate: total rows from table
Drop: to delete the table from database
Delete: particular row from table

30.What are the jdbc drivers

  • JDBC-ODBC Bridge.
  • Native api
  • Network protocol
  • Thin driver

31.What is Dynmic Binding

From the reference of base class we can create object to derived class

32.Difference between string and string buffer

String is an immutable object
String buffer is an mutable Object

33.What is class and object

Class is blue print of program
object is an reference of class

34.What are the access modifer in java

  • Public
  • Private
  • Protected
  • Default

35.Difference between local and global variable

Local Variable Declared in side method
Global Variable Declared inside class out side method


Python Training in Chennai Datascience Training in Chennai  | RPA Training in Chennai  | DevOps Training in Chennai |  AWS Training in Chennai  Azure Training in Chennai  Salesforce Training in ChennaiPowerBI  Training in Chennai MSBI Training in Chennai Java / J2ee Training in Chennai  Software Testing Training in Chennai  | Dotnet Training in Chennai Android Training in Chennai  CCNA Training in Chennai MCSE  Training in Chennai Embedded Systems Training in  Chennai Matlab Training in Chennai  | C, C++ Training in Chennai  |  linux Training in Chennai  |  Unix Training in Chennai Sql / PlSql Training in ChennaiOracle Training in Chennai  | Digital Marketing Training in Chennai  | Automation anywhere Training in Chennai  uipath training in chennaiBlueprism Training in Chennai Rprogramming training in chennai  | Machine Learning training in chennai 


1 comment:

  1. Thanks for giving great kind of information. So useful and practical for me. Thanks for your excellent blog, nice work keep it up thanks for sharing the knowledge.
    AWS Training in Chennai | AWS Training Institute in Chennai

    ReplyDelete