It is environment where JVM executes the byte code.
It is physically exists.
It is an abstract machine where java byte code can be executed.
It is available for many software and hardware platforms.
JVM is platform dependent
Use editor software like:
Use Integrated Development Environment Tools like:
A static method can be invoked without the need for creating an instance of a class.
static method can access static data member and can change the value of it.
finalize() method is invoked just before the object is garbage collected.It is used to perform cleanup processing.
When we overload the constructors, the number of arguments should be different (or) types of arguments should be different (or) sequence of arguments should be different.
Constructors are blocks used to build the object of the class.
Method name are identifiers which represents the behaviour of the class.
Constructor name should be same with as class name.
Methods have return types.
Constructors does not have return types.
In method return statement are used.
In constructor return statement are not used.
Scope of synchronized block is smaller than the method.
• Threads share the same address space.
• Thread is lightweight.
• Cost of communication between process is low.
The classes that extend Throwable class except RuntimeException and Error are known as checked exceptions e.g.IOException,SQLException etc. Checked exceptions are checked at compile-time.
The classes that extend RuntimeException are known as unchecked exceptions e.g. ArithmeticException,NullPointerException etc. Unchecked exceptions are not checked at compile-time.
1. JDBC-ODBC bridge driver
2. Native-API driver (partially java driver)
3. Network Protocol driver (fully java driver)
4. Thin driver (fully java driver)
• Creating connection
• Creating statement
• Executing queries
• Closing connection
If we are using only values (list of values or 1-1 mapping) we can go for the switch case.
finally is an exception handling code section which gets executed whether an exception is raised or not by the try block code segment.
finalize() is a method of Object class which will be executed by the JVM just before garbage collecting object to give a final chance for resource releasing activity.
Class cannot be declared as private.
Constructor can be declared as private.
Class can be declared as final.
Constructor cannot be declared as final.
C++ is basically C with Object-oriented extension
C++ supports operator overloading
C++ supports multiple inheritance of classes
C++ supports structure, pointers and unions
C++ supports method overloading
C++ does not support the constructor overloading
C++ has template classes
Java is true Object-oriented language
Java does not support operator overloading
Java does not support multiple inheritance of classes but it supports interface
Java does not supports structure, pointers and unions
Java supports method overloading as well as method overriding
Java supports the constructor overloading
Java does not have template classes
throw is used to explicitly throw an exception.
checked exceptions can not be propagated with throw only.
throw is followed by an instance.
throw is used within the method.
throws is used to declare an exception
checked exception can be propagated with throws.
throws is followed by class.
throws is used with the method signature
An abstract class can have method body (non-abstract methods).
An abstract class can have instance variables.
An abstract class can have constructor.
An abstract class can have static methods.
You can extends one abstract class.
Interface have only abstract methods
An interface cannot have instance variables.
Interface cannot have constructor.
Interface cannot have static methods.
You can implement multiple interfaces
The wait() method is defined in Object class.
wait() method releases the lock.
The sleep() method is defined in Thread class
The sleep() method is defined in Thread class
ArrayList uses a dynamic array.
ArrayList is not efficient for manipulation because a lot of shifting is required.
ArrayList is better to store and fetch data.
LinkedList uses doubly linked
LinkedList is efficient for manipulation.
LinkedList is better to manipulate data.
Iterator traverses the elements in forward direction only.
Iterator can be used in List, Set and Queue.
ListIterator traverses the elements in backward and forward directions both.
ListIterator can be used in List only.
HashMap is not synchronized.
HashMap can contain one null key and multiple null values.
Hashtable is synchronized.
Hashtable cannot contain any null key or null value
Comparable provides only one sort of sequence.
It provides one method named compareTo().
It is found in java.lang package.
If we implement Comparable interface, actual class is modified.
Comparator provides multiple sort of sequences.
It provides one method named compare
It is found in java.util package.
Actual class is not modified
Abstract class should be declared with keyword abstract.
Abstract class contains both concrete and abstract methods.
Abstract class we can use all the access specifier.
Interface starts with keyword interface and by default it is abstract.
Interface contains only the non-static abstract methods.
Interface we can use only the public access specifier.