Java Difference

Java Difference :

Java Difference
  Java C
1 Java is object oriented. C is not object oriented.
2 Methods cannot accept variable number of argument in java Functions can accept variable number of arguments C.
3 Java offers labeled break and labeled continue statements. C has break and continues statement but not labeled.
4 Java does not include struct, typedef and union keywords. C has keywords struct, typedef, union.
5 struct, enum and union are not valid data types of java. struct, enum and union are valid data types of C.
6 Explicit pointer types are not support in java. C supports explicit pointer types.
7 Java does not support preprocessor directives. C is famous for wide ranges of preprocessor directives like #define, #ifdef and #include statements.
8 Java provides new operators namely >>> and instance of. >>> and instance of operators are not available in C.
  Java C++
1 Java is a true and complete object oriented programming. C++ is an extension of C with object oriented behavior. C++ is not a complete object oriented language as that of java.
2 Java does not provide template classes. C++ offers Template classes.
3 Java supports multiple inheritance using interface. C++ achieves multiple inheritance by permitting classes to inherit from multiple classes.
4 Java does not provide global variables. Global variables can be declared in C++.
5 Java does not support pointers. C++ supports pointers.
6 In java, destruction of objects is performed in finalize method. In C++, destruction of objects is performed by destructor function.
7 Java does not provide header files. C++ has header files.
8 Class is compulsory. Class is optional.
9 Compiler is strong. Compiler is weak.
10 Multiple inheritance is not supported. Multiple inheritance is supported.
11 James Gosling and Sun Microsystems. Bjarne Stroustrup.
12 Garbage Collection supported. No.
  Pass By Value Pass By Reference
1 It means passing a primitive variable into method. It means passing an object reference to the method.
2 Pass by variable means Pass by copy of the variable. When you pass an object variable into method, you must keep in mind that you’re passing the object reference and not the actual object it self.
3 So for the primitive variable, you are always passing a copy of bits in the variable. Passing the copy of reference variable to the method. In other words, both the caller and called method will now have identical copies of the exact (not a copy) object on the heap.
It makes no difference if you’re passing primitive or reference variables, you are always passing a copy of bits int he variable.
    Java JavaScript
1   Java is a compiled language. That is platform independent language. JavaScript is an interpreted language.
2   Fast execution. Slow execution.
3   Java is a developed by sun Microsoft system. JavaScript is a developed by Netscape.
4   The code is the plain text commands that the program written in. The code that you will create in this course can be considered source code.
5 Runs on Virtual machine web-browser
6 Statement terminators ; Semicolon terminated.
7 Designed by James Gosling and Sun Microsystems. Brendan Eich.
  Hash Map Hash Set
1 HashMap  is a implementation of Map interface. HashSet is an implementation of Set Interface.
2 HashMap Stores data in form of  key value pair. HashSet Store only objects.
3 Put method is used to add element in map. Add method is used to add element is Set.
4 In hash map HashCode value is calculated using key object. Here member object is used for calculating hashcode value which can be same for two objects so equal () method is used to check for equality if it returns false that means two objects are different.
5 HashMap is faster than HashSet because unique key is used to access object. HashSet is slower than Hashmap.
  Process Based Multi – tasking Thread Based – tasking
1 A process is essence of program that is executing which running parallel. Thread is such part of multithreaded program which defines separate path or execution.
2 It allows you to run java compiler and text editor at a same time. It doesn’t support java compiler and text editor run simultaneously. Both have performed different tasks.
3 Process multitasking has more overhead than thread multitasking. Thread multitasking has less overhead than process multitasking.
4 Here, it is unable to gain access over idle time of CPU. It allows tasking gain access over idle time taken by CPU.
5 It is not under control of java. It is totally under control of java.
6 Process based multitasking is comparatively heavyweight process comparing to thread based multitasking. Thread based multitasking is known to be lighter eight process.
7 Inter – process communication is expensive and limited. Inter – based communication is inexpensive and context switching from one thread to other.
8 It has slower data rate multitasking. It has faster data are multithreading or tasking.
  &,| &, ||
1 Both arguments should be evaluated always. Second argument evaluation  is optional.
2 Relatively performance is low. Relatively performance is high.
3 Applicable for both integral and boolean types. Applicable only for boolean types but not for integral types.
  Inheritance Abstract class
1 Main difference is methods of a Java interface are implicitly abstract and cannot have implementations. A Java abstract class can have an instance method that implements a default behavior.
2 Variables declared in a Java interface is by default final. An abstract class may contain non-final variables.
3 Members of a Java interface are public by default. A Java abstract class can have the usual flavors of class members like private, protected, etc.
4 Java interface should be implemented using keyword “implements”; A Java abstract class should be extended using keyword “extends”.
5 An interface can extend another Java interface only, An abstract class can extend another Java class and implement multiple Java interfaces.
6 A Java class can implement multiple interfaces. It can extend only one abstract class.
7 Interface is absolutely abstract and cannot be instantiated. A Java abstract class also cannot be instantiated, but can be invoked if a main() exists.
8 Interface contains all public static variable and methods. abstract class static variables, static blocks, concrete methods
9 Interface doesn’t constructor. Abstract class has the constructor
10 The interface can’t have implementation for any of its members. Abstract classes can have implementations for some of its members (Methods).
11 Interfaces can contain only the signature of a method but no body. An abstract class may contain complete or incomplete methods.
12 An interface cannot contain fields, constructors, or destructors and it has only the property’s signature but no implementation. An abstract class can contain fields, constructors, or destructors and implement properties.
13 Interface contains only abstract methods. Abstract class can contain abstract methods, concrete methods or both.
14 Interface contains variables that must be static and final. Abstract class may contain non final and final variables.
15 Interface is used to “implements”. Abstract class is used to “extends”.
16 Interface can be used to achieve multiple inheritance. Abstract class can be used as a single inheritance.
17 Interface is absolutely abstract. Abstract class can be invoked if a main() exists.
18 Access specifiers for methods in interface must be public. Except private we can have any access specifier for methods in abstract class.
19 Variables defined must be public, static , final. Except private variables can have any access specifiers.
20 Multiple Inheritance in java is implemented using interface We cannot achieve multiple inheritance using abstract class.
21 To implement an interface we use implements keyword. To implement an abstract class we use extends keyword.
22 Main difference is methods of a Java interface are implicitly abstract and cannot have implementations. A Java abstract class can have an instance method that implements a default behavior.
23 Variables declared in a Java interface is by default final. An abstract class may contain non-final variables.
24 Members of a Java interface are public by default. A Java abstract class can have the usual flavors of class members like private, protected, etc..
25 A Java class can implement multiple interfaces. It can extend only one abstract class.
26 Interface is absolutely abstract and cannot be instantiated. A Java abstract class also cannot be instantiated, but can be invoked if a main() exists.
27 In comparison with java abstract classes. Java interfaces are slow as it requires extra indirection.
  Interface Abstract class
1 Java interface cannot have a meaning on its own. Java is just a template. Java abstract class cannot be instantiated.
2 Java interface should be implemented by concrete classes. Java abstract class should be inherited or extended by concrete classes.
3 All the methods of java interface are implicit abstract. Java interface cannot have non abstract methods. Java abstract class can have non abstract method.
4 All java interface methods will have only the signature and no method body. Non abstract method of java abstract class can have method definition.
5 All the members of java interface have the access modifier to be public which cannot be modified. Java abstract class and its members can have any access modifiers.
6 Interface is use to be implemented is java programs. Abstract class is use to extend in java program.
7 Object can be taken of interface. Object cannot be considered.
8 Interface is use as reusability of codes. Abstract class is not useful as reusability as codes.
9 Can be define & declare in base class. Method can be declare in abstract class and must be used in subclass.
10 Good choice if you don’t know requirement specification. Good choice if you known partial requirement specification.
11 Method declaration is compulsory to be public and static only. No restrictions (abstract and concrete both method declaration is allowed).
12 Variable declaration is compulsory (static and final). No restrictions on variable declaration.
13 Method declaration is not allowed with static, final, private, protected, synchronized, strctfp or native. No restrictions on abstract class method modifiers.
14 Variables should be initialized inside interface otherwise compile time error will occur. No restrictions to initialize abstract class variables compulsorily.
15 Constructor declarations is not allowed. Constructors are allowed in abstract class.
  Primitive Data Type Non-primitive Data Type
1 The primitive data types are: byte short int long float double boolean  char The non-primitive data types are:  String  Integer ArrayList Random JFrame
2 Primitive-types always have a value. Non-primitives are “Reference-types”.
3 The default initialization value for instance and class (static) variables is 0 (for boolean this is the literal “false”). These include class-based types, either core library defined or user defined, or array types (no class definition).
  Array Type Allowed Element Type
1 Primitive arrays. Any type which can be promoted to declared type.
2 Object type arrays. Either declared type or its child class objects.
3 Interface type arrays. Its implemented class objects.
4 Abstract class type arrays. Its child class objects are allowed.
  Java Application Programs Java Applets
1 Java Application Program can be executed independently. Applications are executed at command line by Java.exe Applet cannot be executed independently. Applets can only be executed inside a Java compatible container, such as a browser or appletviewer.
2 It contain main () method. It has a single point for entry to execution. It does not contain main() method, and does not have a single point of entry for execution.
3 Applications have no inherent security restrictions, and can perform read/write to files in local System. Applets cannot perform read/write to files in local system. This is to provide security.
4 Applications have no special support in HTML for embedding or downloading. Applets can be embedded in HTML pages and downloaded over the Internet.
5 An application runs stand-alone, with the support of a virtual machine. An applet runs under the control of a browser.
6 The true power of Java lies in writing full blown applications. Applets are great for creating dynamic and interactive web applications.
7 In an application execution starts with the main method. Applets don’t have the main method.
8 The applications run on Desktop. Applets are designed for the client site programming purpose, downloaded and run on Browser.
9 The java applications are designed to work with the client as well as server. Applets are designed just for handling the client site problems.
10 Applications are designed to exist in a secure area. The applets can run in secure and unsecured environment.
11 Does not require to inherit any class. Applet need to inherit java.awt.Applet class.
12 Static block is called at time of application call. init() method is called at time of applet creation and destroy() method is called at time of applet destruction.
13 Does not have any other life cycle methods. Has init(), start(), paint(), stop(),  destroy() life cycle methods.
  Java Application Java Applet
1 Must be installed on local machine. Need no explicit installation on local machine.
2 Must be run explicitly within a java compatible machine. Loads and runs it at automatically in a java enabled browser.
3 Can run with or without a graphical user. Must run within a graphical user interface.
4 Starts execution with its main method. Starts execution with its init method.
5 Once stared, manages its own flow of control. Has its flow of executing determined partly by its browser context.
6 Has no inherent security restriction. Has significant security controls to prevent poorly written applets from harming the user’s system.
7 Applets can only be executed inside a Java- compatible container, such as a modern Web Browser. Applications can be e executed from the command line with a small booting utility such as javac.exe or Java.exe.
8 Applets are the programs written specially for distribution over a network. These programs contain information to be delivered to the world and involve user interaction. Applications are system level programs i.e., these programs run in the background and don’t involve user interaction, for example, server administration, security manager, etc.
  Method Overloading Method Overriding
1 It occurs when two or more method have same name with different signature. Overriding occurs when a class declares a method that has same type of signature.
2 It is used in java program frequently because it allows using the same name for group of method that basically has same purpose. Overriding is a compatibility of java program because each overridden method has provided for unique implementation.
3 Overloading allows programmer to use different functionalities to a same named method. Overriding allows programmer to add other functionalities to its method is classes.
4 Java compiler issues on error message because it is unable to determine which from to use. Java compilers issues an error message it method overrides another method has different return type.
5 It allows easy handle to default parameters. It uses super class reference to “super class” object.
6 It can occur within a class in different method. Overriding requires super & sub class for different method.
7 println() is example of overloading. Version of java are an example of overriding.
8 Constructor can be overloaded. Constructor can’t be overridden.
9 Since it involves with only one class inheritance is not involved. Since method overriding occurs between super class and subclass inheritance is involved.
10 In overloading return type need not be the same In overriding return type must be same.
11 Parameters must be different when we do overloading Parameters must be same.
12 Static polymorphism can be achieved using method overloading Dynamic polymorphism can be achieved using method overriding.
13 In overloading one method can’t hide the another. In overriding subclass method hides that of the super class method.
14 Method overloading is performed within a class. Method overriding occurs in two classes that have IS – A relationship.
  Byte stream Character stream
1 Byte stream provides convenient means for handling I/O in byte. Character stream convenient means for handling I/O character.
2 Byte stream were included in java 1.0 version. Character stream were included in 1.1 versions.
3 At the top there are two main abstract classes input stream & output stream. At the top there are two main abstract classes’ reader & writer.
4 Concrete subclasses to handle devices like file, n/w connection and memory buffers. It has to handle Unicode character streams.
5 Read() & write() method respectively read & write byte if data. These methods are overridden from byte stream class. Read() & write() methods respectively use read and write character at data. These methods are overridden from character stream class.
6 Both provide API & partial implementation for input stream output stream whose size is 8 but byte. Both provide API & partial implementation for reader. Writer whose size is 8 but byte.
7 Handle text file. Handle binary file.
  Type casting Type conversion
1 Type casting takes place between incompatible types. Type conversion can take place in both compatible & incompatible types.
2 In java there is no such concept of automatic type casting. In java type conversion is automatically done between compatible types.
3 Type casting is allowed explicitly. Type conversion is allowed implicitly.
4 Wrapper classes and special methods are used in type casting. Narrowing & widening conversion method are used in type conversion.
  Panel Frame
1 Panel is a concrete subclass of container. Frame is concrete subclass of windows.
2 Panel can be created within an applet. Frame can’t be created within an applet.
3 Panel is a window which doesn’t contain menu bar title bar or border. Frame is a typical window which has menu bar, title bat & border.
4 It supports window listener events by default because it runs within applet. Frame is not supporting window listener events because it is an individual window.
5 Setsize() method defined by component. Setsize() method to set dimension of window.
6 When panel is created the output directed to applet, is drawn on panel. Output directly attached with frame window.
7 Setlocation(), setbounds() add() etc. methods is panel. Set visible(), settitle(), init(), start(), show() etc. methods in frame.
  Vector Array
1 Convenient to use & store object. Convenient to use simple data types.
2 Size can be varied for strongly object. Size can be explicitly specified.
3 Different types of objects are stored. Save data type’s based values are stored.
4 Vector has no dimension. An array do have fix dimension.
5 By converting simple type to object by using wrapper class. An array cannot support this particular feature.
  String String Buffer
1 String represents fixed length, immutable character sequences. String buffer represents grow able & writable character sequence.
2 String argument stores characters without reallocation. String buffer allocates reserves room for 16 characters. It uses extra fragmentation for.
3 String can be use as primitive data type. String buffer are not used as data type.
4 Literals directly can be assigning to string. String buffer can’t use literals as string directly.
5 String doesn’t have constructors to define. String buffer defines following stringbuffer() string buffer(int size) string buffer(string s)
  Button JButton
1 Button is component that simulates appearance of PUSH button. JButton class provides functionality like PUSH button.
2 It allows only string to be associate. JButton allows icons & string to be associated.
3 It has following constructor Button(); Button(strings) It has following constructor JButton(icon i); JButton(string s); JButton(string iconi);
4 Button class resides in [java awt.*] package. JButton resides in [javax.swing.*] package.
5 It doesn’t contain any of images on button. It allows to associate image which loads and added in different content pane.
  Applet JApplet
1 Applet class is super class of all applets. Applet that used swing must be subclass JApplet.
2 [java.applet.*;] package required to perform all functionalities of on applet. [java.swing.*;] package is need to import to use swing for any applet through JApplet.
3 Less powerful, flexible and rich compare to JApplet. More powerful, rich and enhanced featured than applet.
4 Call to add() allows to addcompare() in applet. Call to add() allows to add content pane to JApplet.
5 It supports only one type of specific panels in applet. It supports various panes like glass pane, roof pane etc. with JApplet.
  AWT Swing
1 It uses to build user interface. It is a set of class which flexible provides powerful and component.
2 AWT are implemented by specific code. Swing component are not implemented by specific code.
3 There is no such lightweight form code. Lightweight form is use to desirable swing element.
4 [java.awt.*;] & [java.awt.event.*;] packages are to be imported. [javax.swing.*;] package are imported. Though [java.awt.*;] to be implemented.
5 The Abstract Window Toolkit is heavy weight component because every graphical unit will invoke the native methods. The swing is a light weight component because it’s the responsibility of JVM to invoke the native methods.
6 The look and feel of AWT depends upon platform. As swing is based on Model View Controller pattern, the look and feel of swing components in independent of hardware and the operating system.
7 AWT occupies more memory space. Swing occupies less memory space.
8 AWT is less powerful than swing. Swing is extension to AWT and many drawbacks of AWT are removed in Swing.
9 AWT stands for Abstract windows toolkit. Swing is also called as JFC’s (Java Foundation classes).
  AWT components are platform dependent. Swing components are made in purely java and they are platform independent.
10 This feature is not supported in AWT. We can have different look and feel in Swing.
11 These feature is not available in AWT. Swing has many advanced features like JTabel, Jtabbed pane which is not available in AWT. Also. Swing components are called “lightweight” because they do not require a native OS object to implement their functionality. JDialog and JFrame are heavyweight, because they do have a peer. So components like JButton, JTextArea, etc., are lightweight because they do not have an OS peer.
12 With AWT, you have 21 “peers” (one for each control and one for the dialog itself). A “peer” is a widget provided by the operating system, such as a button object or an entry field object. With Swing, you would have only one peer, the operating system’s window object. All of the buttons, entry fields, etc. are drawn by the Swing package on the drawing surface provided by the window object. This is the reason that Swing has more code. It has to draw the button or other control and implement its behavior instead of relying on the host operating system to perform those functions.
13 AWT is a thin layer of code on top of the OS. Swing is much larger. Swing also has very much richer functionality.
14 Using AWT, you have to implement a lot of things yourself. Swing has them built in.
15 A robust event-handling model. 100% Pure Java certified versions of the existing AWT component set (Button, Scrollbar, Label, etc.).
16 A rich set of user interface components. All the features of AWT.
17 Graphics and imaging tools, including shape, color, and font classes. A rich set of higher-level components (such as tree view, list box, and tabbed panes).
18 Layout managers, for flexible window layouts that don’t depend on a particular window size or screen resolution. Pure Java design, no reliance on peers.
19 Data transfer classes, for cut-and-paste through the native platform clipboard. Pluggable Look and Feel.
20 Default layout is FlowLayout. Default layout is BorderLayout.
21 They do not have JVM (Java Model Viewport). All swing components have JVM.
22 Does not support MDI window. MDI can achived using InternalFrame object.
23 Native component. Pure java component.
24 Does not have complex component. Has additional components like JTree, JTable, JProgressBar, Slider etc.
25 Applet cannot have menu. Apple can have menu.
26 List has scrollbar. JList does not support scrolling but this can be done using scroll pane.
27 Components can be added directly on the Frame or window. While adding components on Frame or window, they have to be added on its content pane.
28 Does not have sildePane or TabbedPane. Has slidePane or TabbedPane.
  ByteStreams CharacterStreams
1 Operated on 8 bit (1 byte) data. Operates on 16-bit (2 byte) unicode characters.
2 Input streams/Output streams. Readers/ Writers.
3 Byte streams provide a convenient means for handling input and output of bytes. Character streams provide a convenient means for handling input and output of characters.
4 When reading or writing binary data. When reading or writing text data.
5 ByteStream transfers data in terms of this and bytes; they do not recognize characters. CharacterStream transfers data in terms of characters.
6 ByteStream can transfer any binary or even ASCII data. CharacterStream can transfer only ASCII data.
7 E.g. InputStream, OutputStream E.g. Reader, Writer
8 As BinaryStream don’t recognize characters you cannot put higher level filter on such streams. As CharacterStream recognized characters or you can put filter on it.
  Static (class) method Instance method
1 A method i.e. declared as static is known as static method. A method i.e. not declared as static is known as instance method.
2 Object isnor required to call static method. Object is required to call instance methods.
3 Non – static (instance) member cannot be accessed in static context (static method, static block and static nested class) directly. Static and non – static variables both can be accessed in stance methods.
4 For example: public static int cube(int n) {                return n * n * n; } For example: public void msg() {           ……………… }
  Method Overloading Method Overriding
1 Method overloading increases the readability of the program. Method overriding provides the specific implementation of the method that is already provided by its super class.
2 Method overloading is occurs within the class. Method overriding occurs in two classes that have IS – A relationship.
3 In this case, parameter must be different. In this case, parameter must be same.
  Throw Throws
1 Throw is used to explicit throw an exception. Throws is used to declare an exception.
2 Checked exceptions cannot be propagated with throw only. Checked exception can be propagated with throws.
3 Throw is followed by an instance. Throws is followed by class.
4 Throw is used within the method. Throws is used with the method signature.
5 You cannot throw multiple exceptions. You can declare multiple exception e.g. Public void method() throws IOException, SQLExceptino
6 throw keyword can also be used to break a switch statement without using break keyword. throws keyword can’t  be used to break a switch statement without using break keyword.
7 throw is followed by an instance. throw is followed by an class.
8 throw keyword is used to write throw statement which throws the exception. throws keyword is used with method signature to indicate that particular exceptions are not handled by this method and Call method has to handle it.
9 throw <instance of any exception class>; <method signature> throws <exception class name> [ , <exception class name>]
10 throw keyword can be used with both checked and unchecked kind of  built-in and customized exceptions. throws keyword must be used when a method is throwing checked exception, This will enforce its handling by call method otherwise JVM will throw compile time exception for that.
11 If throw statement is throwing checked exception which is not handled locally, You must have to put the throws clause with checked exception class name for that method signature. throws keyword has not much impact or JVM won’t bother if its throwing unchecked exception, Hence JVM won’t throw any compile time exception for that.
12 The throws keyword must appears at the end of a method’s signature. No such kind of restriction on throws keyword.
  Wait() Sleep()
1 The wait() method is defined in object class. The sleep() method is defined in Thread class.
2 Wait() method releases the lock. The sleep() method doesn’t releases the lock.
  ArrayList Vector
1 ArrayList is not synchronized. Vector is synchronized.
2 ArrayList is not a legacy class. Vector is a legacy class.
3 ArrayList increases its size by 50% of the array size. Vector increases its size by doubling the array size.
4 ArrayList has no default size. While vector has a default size of 10.
5 ArrayList can use only Iterator to access the elements. Vector list can use Iterator and Enumeration Interface to access the elements.
6 The ArrayList increases its array size by 50 percent if it runs out of room. A Vector defaults to doubling the size of its array if it runs out of room.
7 ArrayList is not thread – safe. Vector is thread – safe.
8 ArrayList increases its array size by 50 percent. A Vector defaults to doubling the size of its array.
  ArrayList LinkedList
1 ArrayList uses a dynamic array. LinkedList uses doubly linked list.
2 ArrayList is not efficient for manipulation because a lot of shifting is required. LinkedList is efficient for manipulation.
3 Implements RandomAccess interface we can search randomly all the elements in the list. It extends Abstract sequential List interface which provides sequential access to elements.
4 Searching and retrieval of elements is fast since ArrayList provides random access. Searching and retrieval of elements is slow because of sequential access to elements.
5 Adding and removal of elements in random positions is slow. For example if we want to add element to middle of the list we have to move the elements in the list and then we need to insert the element. Similarly for removing the element we need to follow the same thing. Adding and removal of elements in random positions is fast because there is no need of resizing the array just by updating the node structures with new addresses.
  Constructor Method
1 Constructor is used to initialize the state of an object. Method is used to expose behavior of an object.
2 Constructor must not have return type. Method must have return type.
3 Constructor is invoked implicitly. Method is invoked explicitly.
4 The java compiler provides a default constructor if you don’t have any constructor. Method is not provided by compiler in any case.
5 Constructor name must be same as the class name. Method name may or may not be same as class name.
6 It is not a member of a class as it can neither be inherited nor invoked using dot (.) operator. Dot (.) operator is used to invoke Non static methods via object and static methods via class name.
7 It has no explicit return type. It has explicit return type, if there is nothing to return, the return type must be void.
8 It is used to initialize the objects, members of object and then execute statements if any. Used to execute statements.
9 A no-argument, Default constructor is provided by compiler when no explicit constructor is there. In such case instance members are initialized with their default values (numeric data types are set to 0, char to ‘\0’ and reference variable to null). Local variable must be initialized explicitly.
10 If there is no this() as the first statement, super() will be there as first statement in the constructor. ‘this’ is implicitly invoked on all the member in non-static methods, but need explicit invocation in case of name confliction. Syntax: this.x, this.go()
11 The default constructor will call the default constructor of its super class due to presence of super() as its first statement. ‘super’ can be used to explicitly invoke member of super class (specially used either in case of name conflict or to call method of super class when overridden in sub-class ) syntax: super.member: when name conflict super.method(args if any) : when overridden
12 A constructor can never be abstract or static. A method is of two types defined (implemented) or undefined (abstract). The method implementation can be further categorized as static or non-static. An abstract method can’t be static or final.
13 Can be specified as public, none (default), protected or private. Access-specifier public, none (default), protected or private are applicable.
14 Can’t be final, native, or synchronized. (Constructor can take only access specifier) Can be final, native, static or synchronized.
15 Can be invoked by either a.       new ClassName() b.      this(args if any) c.       super(args if any) d.      getInstance() Can be invoked by Class name in case of static method or by object/this in case of non-static method.
  HashMap Hashtable
1 HashMap is not synchronized in nature. Hashtable is synchronized.
2 HashMap can contain one null key and multiple null values. Hashtable cannot contain any null key or value.
3 The iterator in the HashMap is fail-safe (If you change the map while iterating, you’ll know). The enumerator for the Hashtable is not fail-safe.
5 HashMap works faster. Because of thread – safe, Hashtable is slower than HashMap.
6 Does not guarabtee that order of map remain constant over time. Order of table remain constant over time.
7 Introduced with JDK 1.2. Introduced with JDK 1.0 version, the starting version of Java.
8 Part of Collections framework. Part of legacy classes (the data structures of JDK 1.0 are known as legacy classes).
9 Methods are not synchronized by default. Methods of Hashtable are synchronized by default.
10 Permits null values (either key or value). Does not permit null values (trying to add, throws NullPointerException).
11 Iterator is used for iterating the keys. Enumeration interface is used for iterating keys.
12 Better for non-threaded applications. Safe for multithreaded applications.
13 High performance. Low performance due to synchronization.
14 Iterator in the HashMap is fail – safe. The enumerator for the Hashtable isn’t.
15 HashMap retrieval is not in order (random). Hashtable provides ordered retrieval.
  Iterator Enumeration
1 Iterator can traverse legacy and non – legacy elements. Enumeration can traverse only legacy elements.
2 Iterator is fail – fast. Enumeration is not fail – fast.
3 Iterator is slower than Enumeration. Enumeration is faster than Iterator.
  HashMap TreeMap
1 HashMap is can contain one null key. TreeMap cannot contain any null key.
2 HashMap maintains no order. TreeMap maintains ascending order.
  Method Overloading Method Overriding
1 Method Overloading is used to increase the readability of the program. Method Overriding is used to provide the specific implementation of the method that is already provided by its super class
2 Method Overloading is performed within a class. Method Overriding occurs in two classes that have IS – A relationship.
3 In case of method overloading parameter must be different. In case of method overriding parameter must be same.
  Class Methods Instance Methods
1 Class methods are methods which are declared as static. The method can be called without creating an instance of the class. Instance methods on the other hand require an instance of the class to exist before they can be called, so an instance of a class needs to be created by using the new keyword.
Instance methods operate on specific instances of classes.
2 Class methods can only operate on class members and not on instance members as class methods are unaware of instance members. Instance methods of the class can also not be called from within a class method unless they are being called on an instance of that class.
3 Class methods are methods which are declared as static. The method can be called without creating an instance of the class. Instance methods are not declared as static.
  JAVA C#
1 Less data types. Has more data types
2 Use of keyword static final. Const used to declare class constant.
3 Does not support structures. Support structures.
4 Less versioning support. Better versioning support.
5 Java uses inner classes and interfaces. C# uses built in delegates and events.
6 By default parameters are passed by value. By default parameters are passed by reference.
7 Labeled breaks are used for unconditional branching. goto is used for unconditional branching.
8 Instance of operator is used. Is operator is used.
9 Enumeration not supported by java. Enumeration supported by c#.
10 Does not use indexer. Uses the concept of indexer.
11 Does not include  primitive Types and the functionality to catch arithmetic exceptions. C# includes more primitive types and the functionality to catch arithmetic exceptions.
12 Does not implements properties as part of the language syntax. C# implements properties as part of the language syntax.
13 Java does not allows switch statements to operate on strings. C# allows switch statements to operate on strings.
14 Java  has no ability to alias namespaces. C# has the ability to alias namespaces.
15 Java’s strictfp keyword guarantees that the result of floating point operations remain the same across platforms. No such keyword present.
16 Java supports checked exceptions for better enforcement of error trapping and handling. C# does not  support checked exceptions for better enforcement of error trapping and handling.
    Comparable Comparator
1 Comparable interface in Java is defined in java.lang package. Comparator in Java is defined in java.util package.
2 This interface allows the object to compare itself with another object while sorting the list of such type objects. This interface provide the provision to compare two different objects.
3 The objects those implements Comparable interface are sorted automatically without specifying any other comparator. Comparator is passed as arguments to the method who need to sort some objects.
4 Less flexible. More flexible.
5 Uses compareTo(object2) method. It has compare(object1, object2) method.
6 This interface is not a part of collection API. It belongs to java.lang Packages. This interface belongs to java.util package.
7 Only one sort sequence can be created. Many sort sequences can be created.
8 It is frequently used by the API classes. It used by third-party classes to sort instances.
9 It we implement Comparable interface, actual class is modified. Actual class is not modified.
10 It provides one method named compareTo(). It provides one method named compare().
11 Comparable provides only one sort of sequence. Comparator provides multiple sort of sequences.
12 Comparable interface compares “this” reference with the object specified. If you see then logical difference between these two is Comparator in Java compare two objects provided to him.
13 For sorting objects we use collections.sort(list, new Comparator); For sorting objects we use collections.sort(list);
14 Comparator interface is used when we want to compare two different instances. Comparable is used to compare itself with other instance.
15 Comparator is used when we want custom sorting. Example:  If we take employee class sorting by employeeId is natural sorting. Comparable is used for natural sorting of objects. Example: If we take employee class sorting by ename and age we can say as custom sorting.
16 Should override int compare(T o1, T o2) method which takes two instances. Should override public int compareTo(To) method which takes one instance.
  Swing Applet
1 Swing is light weight Component. Applet is heavy weight Component.
2 Swing have look and feel according to user view you can change look and feel using UIManager. Applet Does not provide this facility.
3 Swing uses for standalone Applications, Swing have main method to execute the program. Applet need HTML code for Run the Applet.
4 Swing uses MVC Model view Controller. Applet not.
5 Swing have its own Layout like most popular Box Layout. Applet uses AWT Layouts like flowlayout.
  Swing have some Thread rules. Applet doesn’t have any rule.
  To execute Swing no need any browser By which we can create stand alone application But Here we have to add container and maintain all action control within frame container. To execute Applet program we should need any one browser like Appletviewer, web browser. Because Applet using browser container to run and all action control within browser container.
  Abstract class Interface
1 An abstract class can provide complete, default code and/or just the details that have to be overridden. An interface cannot provide any code at all, just the signature.
2 In case of abstract class, a class may extend only one abstract class. A Class may implement several interfaces.
3 An abstract class can have non-abstract method. All methods of an Interface are abstract.
4 An abstract class can have instance variables. An Interface cannot have instance variables.
5 An abstract class can have any visibility: public, private, protected. An Interface visibility must be public (or) none.
6 If we add a new method to an abstract class then we have the option of providing default implementation and therefore all the existing code might work properly. If we add a new method to an Interface then we have to track down all the implementations of the interface and define implementation for the new method.
7 An abstract class can contain constructors. An Interface cannot contain constructors.
8 Abstract classes are fast. Interfaces are slow as it requires extra indirection to find corresponding method in the actual class.
  Feature Application Applet
1 main method() Present. Not present.
2 Execution Require JRE. Requires a browser like Chrome etc..
3 Nature Called as standalone application as application can be executed from command prompt. Requires some third party tool help like a browser to execute.
4 Restrictions Can access any data or software available on the system. Cannot access anything on the system except browser’s services.
5 Security Does not require any security. Requires highest security for the system as they are untrusted.
  Parameter Hashtable HashMap
1 ThreadSafe Yes No
2 Synchronized Yes No
3 Performance Due to theadSafe and Synchronized, it is often slower than HashMap. In single threaded environment, it is much faster than Hashtable. So if you do not work in multi thread environment, then hashMap is recommended.
4 Null key Do not allow. Allows null key as well as values
5 Fail fast enumeration in hashtable is not fail fast. Iterator in hashMap is fail fast.
6 Extends It extends Dictionary class which is quite old. It extends AbstractMap class.
7 Alternative No alternative. You can use ConcurrentHashMap for multi thread environment.
8 Introduction HashMap introduced starting from collection framework. Hashtable is even before collection framework.
  ArrayList Vector LinkedList
1 ArrayList is a growable array. Same as ArrayList. Same as ArrayList, except that the element are doubly-linked to one another.
2 It give us a fast iteration and fast random access. Slower than ArrayList. LinkedList may iterate more slowly than ArrayList.
3 ArrayList methods are not synchronized. Vector methods are synchronized for thread safety. LinkedList methods are also not synchronized.
  HashSet TreeSet LinkedHashSet
1 A HashSet is unsorted, unordered, no duplicates. A TreeSet is sorted and no duplicates. It is an Ordered version of HashSet and no duplicates.
2 Inherit from set. Inherit from SortedSet Inherit from set.
3 It is heterogeneous. It is homogeneous. It is heterogeneous.
HashMap Hashtable TreeMap LinkedHashMap
A HashMap is unsorted and unordered Map. A Hashtable is a legacy class. A TreeMap is a sorted Map. LinkedHashMap maintain the insertion order.
Inherit from Map. Inherit from Map. Inherit from SortedMap. But from Java 6 onwards TreeMap implements NavigableMap. Inherit from Map.
HashMap is faster in adding and removing values. Hashtable is slower than HashMap. TreeMap is slower as it first sort the values. LinkedHashMap is faster in iteration among values
  String StringBuffer StringBuilder
1 String is a immutable class. StringBuffer is a mutable class. StringBuilder is a mutable class.
2 New object is created every time when modified. No new object is created, modification is done in existing one. No new object is created, modification is done in existing one.
3 Syntax String s1=”hello”; Syntax StringBuffer sf=new StringBuffer(“hello”); Syntax StringBuilder sb=new StringBuilder(“hello”);
4 StringBuffer methods are synchronized. StringBuilder methods are non-synchronized and added in JDK 5.
5 Use String if you require immutability. Use Stringbuffer in java if you need mutable + thread-safety. Use StringBuilder in Java if you require mutable + without thread-safety.
  AWT – Pros AWT – Cons
1 Speed: use of native peers speeds component performance. Portability: use of native peers creates platform specific limitations. Some components may not function at all on some platforms.
2 Applet Portability: most Web browsers support AWT classes so AWT applets can run without the Java plugin. Third Party Development: the majority of component makers, including Borland and Sun, base new component development on Swing components. There is a much smaller set of AWT components available, thus placing the burden on the programmer to create his or her own AWT-based components.
3 Look and Feel: AWT components more closely reflect the look and feel of the OS they run on. Features: AWT components do not support features like icons and tool-tips.
    .NET Java
1 Controller/Owner Microsoft. Sun + JCP-Partner.
2 Languages C#, C++, Eiffel#, VB, …. Java + possibly others.
3 Communication middleware (RPC, Messaging, Web) .NET Remoting, MSMQ, Web Services (no ebXML). RMI/CORBA, JMS, Web Services (standard compliant).
4 Server Components COM+ Enterprise JavaBeans.
5 XML-Support Consistent Currently not yet completely integrated.
6 Server Pages ASP.NET JSP/Servlets
7 Database access ADO.NET (ADO). JDBC / SQLJ and others.
8 Base libraries Many classes and interface under namespace System.* Many classes under packages java.*
9 GUI-Libs Windows.Forms Web.Forms. Swing/AWT.
10 Runtime .NET CLR Java JVM
11 Interop (call-in/call-out) PInvoke JNI
12 InteropMiddleware COM/COM+ (COM Interop) CORBA, JMS
13 Legacy Integration Host Integration Server JCA
    Java Server Pages Active Server Pages
1 Web Server Support Most popular web servers including Apache, Netscape, and Microsoft IIS can be easily enabled with JSP. Native support only within Microsoft IIS or Personal Web Server. Support for select servers using third-party products.
2 Platform Support Platform independent. Runs on all Java-enabled platforms. Is fully supported under Windows. Deployment on other platforms is cumbersome due to reliance on the Win32-based component model.
3 Component Model Relies on reusable, cross-platform components like JavaBeans, Enterprise JavaBeans, and custom tag libraries. Uses the Win32-based COM component model.
4 Scripting Can use the Java programming language or JavaScript. Supports VBScript and JScript for scripting.
5 Security Works with the Java security model. Can work with the Windows NT security architecture.
  Database Access Uses JDBC for data access. Uses Active Data Objects for data access.
6 Customizable Tags JSP is extensible with custom tag libraries. Cannot use custom tag libraries and is not extensible.
  Swing- Pros Swing- Cons
1 Portability: Pure Java design provides for fewer platforms specific limitations. Applet Portability: Most Web browsers do not include the Swing classes, so the Java plug-in must be used.
2 Behavior: Pure Java design allows for a greater range of behavior for Swing components since they are not limited by the native peers that AWT uses. Performance: Swing components are generally slower and buggier than AWT, due to both the fact that they are pure Java and to video issues on various platforms. Since Swing components handle their own painting (rather than using native API’s like DirectX on Windows) you may run into graphical glitches.
3 Features: Swing supports a wider range of features like icons and pop-up tool-tips for components. Look and Feel: Even when Swing components are set to use the look and feel of the OS they are run on, they may not look like their native counterparts.
4 Vendor Support: Swing development is more active. Sun puts much more energy into making Swing robust.  
5 Look and Feel: The pluggable look and feel lets you design a single set of GUI components that can automatically have the look and feel of any OS platform (Microsoft Windows, Solaris, Macintosh, etc.). It also makes it easier to make global changes to your Java programs that provide greater accessibility (like picking a hi-contrast color scheme or changing all the fonts in all dialogs, etc.).  
  Multiprocessing Multithreading
1 In Multitasking operating system tasks are known as heavy-weight process. In Multithreading environment tasks are light weight process or threads.
2 Multitasking process takes a separate address space. These are the different programs run on a single system. Threads on other hand share the same address space and co-operatively share the same heavy weight process.
3 Inter-process communication is expensive and limited. Inter-thread communication is very light-weight and pervasive.
4 Context switching, changing the running process, is also heavy-weight. Context switching is fast and an integral part of running any one program.
  Reader/Writer InputStream/Output Stream
1 Use to read/write characters from file. Use to read/write bytes from file.
2 Only read/write text file that contain only characters. Read/write file that contains image, videos, audios, text etc
3 Classes used by Character Streams are FileReader and FileWriter that extends InputStreamReader and OutputStreamReader abstract classes respectively. Classes used by Byte Streams are InputStream and outputStream both are abstract classes that is extends by the FileInputStream and FileOutputStream respectively.
  Serializable Externalizable
1 This a markable interface with no field and method. This contains two methods readExternal() and writeExternal().
2 This interface provides a inbuilt serialization mechanism. This interface is designed to give you control over the serialization mechanism.
3 This interface provides a default serialization mechanism. This interface instead of relying on default Java Serialization provides flexibility to control this mechanism.
  Thread Runnable
1 Thread is a class that is use to create threads. Runnable is an interface that is use to create threads.
2 When we extends Thread class, after that we can’t extend any other class which you required (As java doesn’t support multiple inheritance). When we implements Runnable, we can save a space for your class to extend any other class in future.
3 When we extends Thread class, each of our thread creates unique object and associate with it. When we implements Runnable, it shares the same object to multiple threads.
  JDK JVM
1 Java Development Kit. Java Virtual Machine.
2 Environment path set. Run program .java.
3   Platform independent.
  Yield Sleep
1 Method pauses the currently executing thread temporarily for giving a chance to the remaining waiting threads of the same priority to execute. If there is no waiting thread or all the waiting threads have a lower priority then the same thread will continue its execution. The yielded thread when it will get the chance for execution is decided by the thread scheduler whose behavior is vendor dependent. sleep() Based on our requirement we can make a thread to be in sleeping state for a specified period of time.
2 yield() basically means that the thread is not doing anything particularly important and if any other threads or processes need to be run, they should. Otherwise, the current thread will continue to run. sleep() causes the thread to definitely stop executing for a given amount of time; if no other thread or process needs to be run, the CPU will be idle (and probably enter a power saving mode).
3 Yield is used to get the running thread into out of runnable state with the same priority. A thread might yield, then immediately re-enter to the running state. May be you can confused on that, read about thread priority and it’ll give an idea what exactly happen. Sleep is used to delay the execution for a period of time, and sleeping thread is guaranteed for sleep at least the specified time. But it not guaranteed that newly weak up thread will actually returning to running.
4 yield() method pauses the currently executing thread temporarily for giving a chance to the remaining waiting threads of the same priority to execute. If there is no waiting thread or all the waiting threads have a lower priority then the same thread will continue its execution. The yielded thread when it will get the chance for execution is decided by the thread scheduler whose behavior is vendor dependent. Based on our requirement we can make a thread to be in sleeping state for a specified period of time(hope not much explanation required for our favorite method).
5 This method is used bring a thread from wait state to ready state. This method is used suspend a thread for a specific period of time.
6 yeild method Causes the currently executing thread object to temporarily pause and allow other threads THREAD OF SAME PRIORITY to execute. sleep method Causes the currently executing thread to sleep (temporarily cease execution) for the specified number of milliseconds, subject to the precision and accuracy of system timers and schedulers.
  java.lang.Comparable java.util.Comparator
1 int objOne.compareTo(objTwo) int compare(objOne, objTwo)
2 Returns negative if objOne < objTwo zero if objOne == objTwo positive if objOne > objTwo Same as Comparable
3 You must modify the class whose instances you want to sort. You build a class separate from the class whose instances you want to sort.
4 Only one sort sequence can be created. Must sort sequences can be created.
5 Implemented frequently in the API by: String, Wrapper classes, Date, Calendar… Meant to be implemented to sort instances of third – party classes.
  Encapsulation Abstraction
1 Encapsulation is hiding the implementation details which may or may not be for generic or specialized behavior(s). Abstraction is providing a generalization (say, over a set of behaviors).
2 Encapsulation means hiding the internal details or mechanics of how an object does something. Abstraction lets you focus on what the object does instead of how it does it.
3 Encapsulation (information hiding) prevents clients from seeing it’s inside view, where the behavior of the abstraction is implemented. Abstraction focuses on the outside view of an object (i.e. the interface).
4 Encapsulation is the Implementation. Abstraction solves the problem in the design side.
5 Encapsulation is the deliverable of Abstraction. Encapsulation barely talks about grouping up your abstraction to suit the developer needs.  
  Server Socket Client Socket
1 Server socket class is used in server in TCP/IP protocol. Socket class is used in client in TCP/IP protocol.
2 It is designed to be a listener for client. It is designed to connect client with server.
3 It needs accept() method to listen client’s request. It is not having such method.
4 It uses following constructors: Server socket (int port); server socket (int port, int maxqurue); server socket (int port, int maxqueue, int address, local address); It uses following constructors: socket (string, host name, int port); socket ( inet address, ip addresses, int port);
    POP OOP
1 Importance In POP, Importance is not given to data but to functions as well as sequence of actions to be done. In OOP, Importance is given to the data rather than procedures or functions because it works as a real world.
2 Approach POP follows Top Down approach. OOP follows Bottom Up approach.
3 Access Specifiers POP does not have any access specifier. OOP has access specifiers named Public, Private, Protected, etc.
4   Data Moving In POP, Data can move freely from function to function in the system. In OOP, objects can move and communicate with each other through member functions.
5   Expansion To add new data and function in POP is not so easy. OOP provides an easy way to add new data and function.
6   Data Access In POP, Most function uses Global data for sharing that can be accessed freely from function to function in the system. In OOP, data can not move easily from function to function, it can be kept public or private so we can control the access of data.
7   Data Hiding POP does not have any proper way for hiding data so it is less secure. OOP provides Data Hiding so provides more security.
8 Overloading   In POP, Overloading is not possible. In OOP, overloading is possible in the form of Function Overloading and Operator Overloading.
9 Examples Example of POP are: C, VB, FORTRAN, Pascal. Example of OOP are: C++, JAVA, VB.NET, C#.NET.
10   Main program is divided into small parts depending on the functions. Main program is divided into small object depending on the problem.
11   The Different parts of the program connect with each other by parameter passing & using operating system.  Functions of object linked with object using message passing.
12   Every function contains different data. Data & functions of each individual object act like a single unit.
13   Functions get more importance than data in program. Data gets more importance than functions in program.
14   Most of the functions use global data. Each object controls its own data.
15   Same data may be transfer from one function to another Data does not possible transfer from one object to another.
    There is no perfect way for data hiding. Data hiding possible in OOP which prevent illegal access of function from outside of it. This is one of the best advantages of OOP also.
16   Functions communicate with other functions maintaining as usual rules. One object link with other using the message passing.
17   More data or functions cannot be added with program if necessary. For this purpose full program need to be change. More data or functions can be added with program if necessary. For this purpose full program need not to be change.
18   To add new data in program user should be ensure that function allows it. Message passing ensure the permission of accessing member of an object from other object.
19   Top down process is followed for program design. Bottom up process is followed for program design.
  Stack Heap
1 Used to store local variables, address of the objects and method calls. Used to store Object values in java.
2 When there is shortage of memory in stack, JVM throws java.lang.StackOverflowError. When there is shortage of memory in heap JVM throws java.lang.OutOfMemoryError.
3 Data in the stack dies or gets deleted once the block of code or method call terminates. Data in the heap dies till the object gets garbage collected.
4 Stack is faster when compared to heap. Heap is slower when compared to stack.
5 Variables created in stack are visible only to the thread which it has created. Objects in heap are visible to all threads.
  Process Thread
1 Program in execution. Separate path of execution in program. One or more threads is called as process.
2 Processes are heavy weight. Threads are light weight.
3 Inter process communication is expensive. Inter thread communication is less expensive compared to processes.
4 Context switching from one process to another is costly. Context switching between threads is low cost.
5 Processes have their own address. Threads shares the address space of the process that created it.
6 Processes have their own copy of the data segment of the parent process. Threads have direct access to the data segment of its process.
7 Processes must use interprocess communication to communicate with sibling processes. Threads can directly communicate with other threads of its process.
8 Processes have considerable download. Threads have almost no overhead.
9 Processes can not exercise control over child processes. Threads can exercise considerable control over threads of the same process.
10 Changes to the parent does not affect child processes. Changes to the main thread (cancellation, priority change, etc.) may affect the behavior of the other threads of the process.
  IS – A relationship HAS – A RELATIONSHIP
1 Is a relationship also known as inheritance. Has a relationship also known as composition or aggregation.
2 For IS-A relationship we uses extends keyword. For Has a relationship we use new keyword.
3 Ex: Car is a vehicle. Ex: Car has an engine. We cannot say Car is an engine.
4 The main advantage of inheritance is reusability of code. The main advantage of has a relationship is reusability of code.
  Overriding Overloading
1 In overriding method names must be same. In overloading method names must be same.
2 Argument List must be same. Argument list must be different at least order of arguments.
3 Return type can be same or we can return covariant type. From 1.5 covariant types are allowed. Return type can be different in overloading.
4 We can’t increase the level of checked exceptions. No restrictions for unchecked exceptions. In overloading different exceptions can be thrown.
5 A method can only be overridden in subclass. A method can be overloaded in same class or subclass.
6 Private, static and final variables cannot be overridden. Private, static and final variables can be overloaded.
7 In overriding which method is called is decided at runtime based on the type of object referenced at run time. In overloading which method to call is decided at compile time based on reference type.
8 Overriding is also known as Runtime polymorphism, dynamic polymorphism or late binding. Overloading is also known as Compile time polymorphism, static polymorphism or early binding.
9 Virtual table is maintained for overridden functions. In it, there is no need to maintain virtual table.
  Unchecked Exception Checked Exception
1 All the subclasses of RuntimeException are called unchecked exception. All subclasses of Throwable class except RuntimeException are called as checked exceptions
2 Unchecked exceptions need not be handled at compile time. Checked Exceptions need to be handled at compile time.
3 These exceptions arise mostly due to coding mistakes in our program.  
4 ArrayIndexOutOfBoundsException, ClassCastException, IndexOutOfBoundException SqlException, FileNotFoundException, ClassNotFoundException
5 All sub classes of RunTimeException and sub classes of java.lang.Error are unchecked exceptions. All sub classes of java.lang.Exception Class except sub classes of RunTimeException are checked exceptions.
  Array ArrayList
1 While creating array we have to know the size. But it is not required to know size while creating ArrayList, because arraylist grows dynamically.
2 To put an element in to array we use the following syntax: String array[] = newString[5];array[1] = “java”; We must know specific location to insert an element in to array. If we try to put element in index which is out of range we get ArrayIndexOutOfBounds Exception We can add element to arraylist with following Syntax: List<String> stringList = new ArrayList<String>();stringList.add(“java”);
3 Arrays are static. ArrayList is dynamic.
4 We can store objects and primitives. We can store only primitives prior to 1.5. From 1.5 we can store even objects also.
5 We have to manually write logic for inserting and removing elements. Just a method call would add or remove elements from list.
6 Arrays are faster. Arraylist is slower.
7   Arraylist is implemented using arrays.
  Iterator ListIterator
1 Iterator interface provides the facility of iterating the elements in forward direction only. ListIterator Interface is used to traverse the element in backward and forward direction.
2 No. ListIterator is the child interface of Iterator.
3 Can do remove operation only on elements. Can remove, add and replace elements.
4 Method is remove(). Methods are remove(), add() and set().
5 iterator() method returns an object of Iterator. listIterator() method returns an object of ListItertor.
6 iterator() method is available for all collections. That is, Iterator can be used for all collection classes. listIterator() method is available for those collections that implement List interface. That is, descendents of List interface only can use ListIterator.
  Arrays Collections
1 Arrays are fixed in size. Collections are growable in nature.
2 Memory point of view arrays are not recommended to use. Memory point of view collections are highly recommended to use.
3 Performance point of view arrays are recommended to use. Performance point of view collections are not recommended to use.
4 Arrays can hold only homogeneous data type elements. Collections can hold both homogeneous and hetetogeneous elements.
5 There is no underlying data structure for arrays and hence there is no readymade method support. Every collection class is implemented based on some standard data structure and hence readymade method support is available.
6 Arrays can hold both primitive and object types. Collections can hold only objects but not primitives.
  == (double equal operator) .equals() method
1 It is an operator applicable for both primitives and object references. It is a method applicable only for object references but not for primitives.
2 In the case of primitive == means for content compression, but in the case of object references == operator means for reference compression. By default .equal() method represent in object class is also means for reference compression.
3 We can’t override == operator for content compression in object references. We can override .equal() method for content compression.
4 If there is no relationship between argument types then we will get compile time error saying incompatible types. If there is no relationship between argument types then .equal() method simply returns false and we won’t get any compile time error and runtime error.
5 For any object reference r, r == null is always false. For any object reference r, r.equals(null) is also returns false.
    Class Object
1 Definition Class is mechanism of binding data members and associated methods in a single unit. Instance of class or variable of class.
2 Existence It is logical existence. It is physical existence.
3 Memory Allocation Memory space is not allocated, when it is created. Memory space is allocated, when it is created.
4 Declaration/definition Definition is created once. It is created many times as you require.
  Abstract class Interface
1 A class of only concrete or only Abstract or both. Only abstract methods.
2 Any java class can extend only one abstract class. A class can implements any no. of interfaces (this gives multiple interface inheritance).
3 It won’t force the programmer to implement / override all its methods. It forces the programmer to implement all its methods.
4 It takes less execution time than interface. Interface takes more execution time due to its complex hierarchy.
5 It allows constructor. It won’t allow any constructor.
6 This class can’t be instantiated directly. It can’t be instantiated but it can refer to its subclass objects.
7 It gives less scope than an interface. It gives more scope than an abstract class.
8 It allows both variable and constants declaration. It allows methods declarations whenever we want. But it involves complexity.
9 It gives reusability hence it can’t be declared as “final”. Since they give reusability hence they must not be declared as “final”.
10 A class must be abstract when it consist at least one abstract method. By default, methods are public, abstract variables are public, static, final.
  final Abstract Class
1 final methods we can’t override. abstract methods compulsory we should override in the child class to provide implementation.
2 final class we can’t create child class. abstract class we should compulsory create child class to provide implementation.
3 final class cannot contain abstract methods. abstract class can contain final method.
  JFrame JDialog
1 JFrame is a normal window with its normal buttons (optionally) and decorations. JDialog on the other side does not have a maximize and minimize buttons and usually are created with JOptionPane static methods, and are better fit to make them modal (they block other components until they are closed).
2 JFrame is a fully-functional Windows window. JDialog is a popup-sort-of window.
3 JFrame for example lack modality. JDialog lack WindowState.
  Run time error Compile time error
1 A run-time error occurs when you are running the program. A compile-time error occurs when you attempt to compile the program.
2 Example: the program asks you for enter a number, you enter a letter then it will arise run time error… Example: syntax error
  static variable Instance variable
1 Defined at Class Level. Defined at Instance/Object Level.
2 Static Variables are initialized, loaded with Class itself. Instance variable initialized when Object for that Class is instantiated.
3 A static variable is shared by all instances of the class. Instance variable each instance of class have different copy.
4 Static variable the field is allocated when the class is created. It belongs to the class and not any object of the class. It is class variable. Instance variable the field is allocated when the class is instantiated to the class is called instance variable or non-static variable.
5 Static variables are whose memory space is creating only once when the class is loaded by class loader subsystem (a part of JVM) in the main memory irrespective of number of objects. An instance variable is one whose memory space is creating each and every time whenever an object is created.
6 Programmatically static variable declaration must be preceded by keyword static. Programmatically instance variable declaration should not be preceded by keyword static.
7 Instance variable must be accessed with respect to object name i.e., objname.varname; Static variables must be accessed with respect to class name i.e., classname.varname;
8 Value of static variable is always recommended for sharable. Value of instance variable is not sharable.
9 Static variable are also known as class level data members since they are dependent on classes. Instance variable are also known as object level data members since they are dependent on objects.
  Non – static variable Static variable
1 These variable should not be preceded by any static keyword Example class A {        int a; } These variables are preceded by static keyword. Example class  A {      static int b; }
2 Memory is allocated for these variable whenever an object is created. Memory is allocated for these variable at the time of loading of the class.
3 Memory is allocated multiple time whenever a new object is created. Memory is allocated for these variable only once in the program.
4 Non – static variable also known as instance variable while because memory is allocated whenever instance is created. Memory is allocated at the time of loading of class so that these are also known as class variable.
5 Non-static variable are specific to an object. Static variable are common for every object that means there memory location can be sharable by every object reference or same class.
6 Non-static variable can access with object reference. Syntax Obj_ref.var_name Static variable can access with class reference. Syntax Class_name.var_name
  Non – Static method Static method
1 These method never be preceded by static keyword Example void fun1() {        ……        …… } These method always preceded by static keyword Example static void  fun2() {        ……        …… }
2 Memory is allocated multiple time whenever method is calling. Memory is allocated only once at the time of loading.
3 It is specific to an object so that these are also known as instance method. These are common to every object so that it is also known as member method or class method.
4 These methods always access with object reference. Syntax Objref.methodname(); These property always access with class reference. Syntax className.methodname();
5 If any method wants to be execute multiple time that can be declare as non static. If any method wants to be execute only once in the program that can be declare as static.
  Event Source EventListener / Event Destination
1 Source is component which generates events. Listener is one which generated by source components.
2 One source can delegate event to more than one listeners. More than one listeners handle on source.
3 In source there is no need to implement an interface. EventListener must implement corresponding interface.
4 E.g. Button ActionListener
  Applet Frame
1 Applet requires browser to run. Frames can be independent or standalone, they do not required browser to run.
2 Applet does not support menus (JApplet supports Menus). Frame supports Menus.
3 Applet supports methods (events) like init(), start(), stop() and destroy(). Frames do not support such events.
4 Default Layout Manager for Applet is “”FlowLayout Manager”. Default Layout Manager for frame is “BorderLayout Manager”.
  try catch
1 Generally errors can be generated within try block. Error is generally handled by catch block.
2 For one try block there can be more than one catch blocks. For many catch block, there can only one try block.
3 Try block don’t required any arguments. Catch block requires execution data types as its argument.
4 If no error is generated the try block is executed. If no error is generated catch block is not executed.
  GridLayout GridBagLayout
1 It divides containers in same size of cells. It divides containers in different size of cells.
2 Constructor requires no. of rows and no. of columns as argument. Constructor does not require no. of rows and no. of columns, they divided dynamically.
3 This layout manager does not respect components height and width. In can supports components preferred height and width.
4 GridLayout is less flexible than GridBagLayout. GridBagLayout is more flexible than GridLayout.
  Exception Runtime Exception
1 Exception is required to catch by the catch block. Runtime exception do not need to catch width catch block.
2 Exception is a subclass of throwable class. Runtime Exception is a subclass of Exception class.
3 E.g. Interrupted Exception. E.g. Divide by Zero.
  Volatile Synchronized
1 Get a global lock on the variable. Get a global lock on the monitor.
2 Update the one variable from main memory. Update all shared variables that have been accessed from main memory.
3   Process some statements.
4 Write any change of the one variable back to main memory. Write all shared variables that have been changed back to main memory.
5 Release the lock. Release the lock.
  List Set
1 List can contain duplicate values. Set doesn’t allow. Set allows only to unique elements.
2 List allows retrieval of data to be in same order in the way it is inserted. Set doesn’t ensures the sequence in which data can be retrieved.(Except HashSet)

  • Difference between overloading and overriding
  • First difference is that, former occur during compile time while later occur during runtime.
  • Second difference is that, you can overload method in same class but you can only override method in sub class.
  • Third difference is that, you can overload static method in java but you can not override static method in java. In face when you declare same method in sub class it’s known as method hiding because it hide super class method instead of overriding it.
  • Overloaded methods are bounded using static binding and type of reference variable is used, while overridden method are bounded using dynamic bonding based upon actual object.
  • Rules of overloading and overriding is different in java. In order to overload a method you need to change its method signature but that is not required for overriding any method in java.
  • Another difference between method overloading and overriding is that private and final method can not be override but can be overloaded in java.
  • Overloaded method are fast as compare to overridden method in java.
  • Overriding is an example of run time polymorphism. Overriding is an example of compile time polymorphism.
  • One method can overload unlimited number of times. Method overriding can be done only once per method in the sub class.
  • Difference Between ByteStream class and CharacterStream class in Java
  • Character oriented streams are also known as reader and writer streams Byte oriented streams are known as data streams-Data input stream and Data output stream
  • Character streams are often wrappers of byte streams.
  • Byte streams are useful when reading from files or sockets and character streams are for from user.
  • Byte streams does not care about any type of encoding. It reads byte (8 bits) by byte. CharacterStream reads two bytes and treats as character and decodes.
  • Binary streams – contain binary data. Character streams – contain character data.
  • From a binary stream, when you read a value of any primitive data type, you always know that how many bytes it consists. But when you read an data from a character stream, you have to determine how many characters from the stream generate the value.
  • Characters oriented are tied to datatype. Only string type or character type can be read through it while byte oriented are not tied to any datatype, data of any datatype can be read(except string) just you have to specify it.
  • Character oriented streams use character encoding scheme (UNICODE) while byte oriented do not use any encoding scheme.
  • Byte Streams are not much effective compared to character stream.
  • Data transfer data is low in Byte Stream as compared to character stream.
  • Difference between class and object in java
  • An object is an instance of a class.
  • Objects have a lifespan but classes do not.
  • A class is a general concept (like an Animal), an object is a very specific embodiment of that class. (Like a lion, cat, or a zebra).
  • A class is just like the blueprint of the object, and the object is just like the product that is made by using the blueprint.
  • A class can be used to create any number of objects.
  • An object will always occupy some memory space in the system’s hard disk drive, but a class will  not.
  • A class is just like a template from which an object is created.
  • Constituents:
  • Class :

Class: Collection of variables and functions.

Object: Has access to the methods of the class, but not its data in the member variables.

  1. Class : The format is given as follows:
{
functions.....
variables.....
}

Object: The format is given as follows:

class-name object-name=new class-name();
  1. You can create subclasses, but not sub-objects.
  2. Classes do not hold any information, while an object does.
  3. You define all the properties and functions in a class, while you use them in an object.
  • Difference between AWT and Swing
  • Swing is also called as JFC’s (Java Foundation classes) and AWT stands for Abstract windows toolkit.
  • AWT  components  are  called  Heavyweight  component  and  Swings  are  called  light  weight  component  because swing components sits on the top of AWT components and do the work.
  • Swing components require javax.swing package where as AWT components require java.awt package.
  • Swings components are made in purely java and they are platform independent whereas AWT components are platform dependent.
  • We can have different look and feel in Swing whereas this feature is not supported in AWT.
  • Swing has many advanced features like JTabel, Jtabbed pane which is not available in AWT also. Swing components  are  called  “lightweight”  because  they  do  not  require  a  native  OS  object  to  implement  their functionality.  JDialog  and  JFrame  are  heavyweight,  because  they  do  have  a  peer.  So components like JButton, JTextArea, etc., are lightweight because they do not have an OS peer.
  • With AWT, you have 21 “peers” (one for each control and one for the dialog itself). A “peer” is a widget provided by the operating system, such as a button object or an entry field object.
  • With Swing, you would have only one peer, the operating system’s window object. All of the buttons, entry fields, etc. are drawn by the Swing package on the drawing surface provided by the window object. This is the reason that Swing has more code. It has to draw the button or other control and implement its behavior instead of relying on the host operating system to perform those functions. 
  • Several consequences result from this difference between AWT and Swing. AWT is a thin layer of code on top of the OS, whereas Swing is much larger. Swing also has very much richer functionality. 
  • Using  AWT,  you  have  to  implement  a  lot  of  things  yourself,  while  Swing  has  them  built  in.  For  GUIintensive  work,  AWT  feels  very  primitive  to  work  with  compared  to  Swing.  Because Swing implements GUI functionality itself rather than relying on the host OS, it can offer a richer environment on all platforms Java runs on.
  • Difference between Swing and Applet
  • Swing is light weight component while applet is not.
  • Applet have no main method, but swing have.
  • Swing have look and feel while Applet Does not provide this facility
  • Swing uses for standalone Applications while Applet need HTML code for Run the Applet
  • Swing have its own Layout while Applet uses AWT Layout.
  • Swing Using UIManager. Swing have look and feel according to user view u can change look and feel.  AppletDoes not provide this facility.
  • Swing uses MVC Model view Controller. Applet not.
  • Swing have its own Layout ..like most popular Box Layout Applet uses AWT Layouts.. like flowlayout.
  • Swing have some Thread rules. Applet doesn’t have any rule.
  • Used to create Desktop application in Java. Used to create UI in the Webbased Application.
  • Swing APIs are defined in javax.swing package. All the Applet APIs are included in java.applet package.
  • Difference between throw and throws in Exception handling
  • throw keyword is used to throw Exception from any method or static block in Java while throws keyword, used in  method declaration, denoted which Exception can possible be thrown by this method.
  • If any method throws checked Exception as shown in below Example, than caller can either handle this exception by catching it or can re throw it by declaring another throws clause in method declaration.
public void read() throws IOException
{
throw new IOException();
}

failure to either catch or declaring throws in  method signature will result in compile time error.

  • throw keyword can be used in switch case in Java  but throws keyword can not be used anywhere except on method declaration line.
  • As per Rules of overriding in Java, overriding method can not throw Checked Exception higher in hierarchy than overridden method. This is rules for throws clause while overriding method in Java.
  • throw transfers control to caller, while throws is suggest for information and compiler checking.
  • Both Checked and Unchecked Exception can be declared to be thrown using throws clause in Java.”throw” is used to handle user-defined exception. JVM handles the exceptions which are specified by “throws” 
  • JDBC vs ODBC
  • ODBC cannot be directly used with Java because it uses a C interface. Calls from Java to native C code have a  number of drawbacks in the security, implementation, robustness and automatic portability of applications.
  • ODBC makes use of pointers which have been totally removed from Java ODBC mixes simple and advanced features together and has complex options for simple queries. But JDBC is designed to keep things simple while allowing advanced capabilities when required.
  • JDBC API is a natural Java Interface and is built on ODBC. JDBC retains some of the basic features of ODBC like X/Open SQL Call Level Interface.
  • JDBC is to Java programs and ODBC is to programs written in languages other than Java.
  • Difference between Interface and Abstract Class
  • Main difference is methods of a Java interface are implicitly abstract and cannot have implementations. A Java abstract class can have instance methods that implements a default behavior.
  • Variables declared in a Java interface is by default final. An abstract class may contain non-final   variables.
  • Members of a Java interface are public by default. A Java abstract class can have the usual flavors of class members like private, protected, etc..
  • Java interface should be implemented using keyword “implements”; A Java abstract class should be extended using keyword “extends”.
  • An interface can extend another Java interface only, an abstract class can extend another Java class and implement multiple Java interfaces. A Java class can implement multiple interfaces but it can extend only one abstract class.
  • Interface is absolutely abstract and cannot be instantiated; A Java abstract class also cannot be instantiated, but can be invoked if a main() exists. In comparison with java abstract classes, java interfaces are slow as it requires extra indirection.
  • Difference between super and this in java
  • this” refers to the current class where as “super” refers directly to its immediate above super class.
  • private variables cannot be accessed in a inherited class by using “this”, whereas by using “super” we can easily access the private variables in its super class.
  • Difference between Application & Applet
  • Applets can be embedded in HTML pages and downloaded over the Internet whereas Applications have no special support in HTML for embedding or downloading.
  • Applets can only be executed inside a java compatible container, such as a browser or appletviewer whereas Applications are executed at command line by java.exe or jview.exe.
  • Applets execute under strict security limitations that disallow certain operations(sandbox model  security) whereas Applications have no inherent security restrictions.
  • Applets don’t have the main() method as in applications. Instead they operate on an entirely different mechanism where they are initialized by init(),started by start(),stopped by stop() or destroyed by destroy().
  • Difference between Java and C++
  • C++ supports pointers whereas Java does not pointers. But when many programmers questioned how you can work without pointers, the promoters began saying “Restricted pointers.” So we can say java supports restricted pointers.
  • At compilation time Java Source code converts into byte code .The interpreter execute this byte code at run time and gives output .Java is interpreted for the most part and hence platform independent. C++ run and compile using compiler which converts source code into machine level languages so c++ is plate from dependents.
  • Java is platform independent language but c++ is depends upon operating system machine etc.
  • Java uses compiler and interpreter both and in c++ their is only compiler
  • C++ supports operator overloading multiple inheritance but java does not.
  • C++ is more nearer to hardware then Java
  • Everything is an object in Java (Single root hierarchy as everything gets derived from java.lang.Object).
  • Java does is a similar to C++ but not have all the complicated aspects of C++ (ex: Pointers, templates, unions, operator overloading, structures etc..) >>Java does not support conditional compile (#ifdef/#ifndef type).
  • Thread support is built-in Java but not in C++.
  • Internet support  is built-in Java but not in C++.
  • Java does not support header file, include library files just like C++ .Java use import to include different Classes and methods.
  • Java does not support default arguments like C++.
  • There is no scope resolution operator “:: “in Java.
  • There is no “goto” statement in Java.
  • Exception and Auto Garbage Collector handling in Java is different because there are no destructors into Java.
  • Java has method overloading, but no operator overloading  just like c++.
  • The String class does use the + and += operators to concatenate strings and String expressions use automatic type conversion,
  • Java support call by value only.
  • Java does not support unsigned integer.
  • Difference between serialization and deserialization
  • Whenever the state of an Object is saved to some file, the process is known as Serialization. Deserialization is the process of creating the object back  from the serialized file.
  • serialization is the process of saving the object state into output stream. Deserialization is the process of getting the object state from output stream.
  • Package vs Directory
  • The package of Java, at execution time, is converted into a directory (folder) by the operating system. The java.util is converted as java\util and java.awt.event is treated as java\awt\event by the OS. The asterisk * is a wild character of Windows which means all the files (means all the classes).
  • What is the difference between final and abstract?
  • For abstract methods compulsory we should override in the child class to provide implementation.  Whereas for final methods we can’t override hence abstract final combination is illegal for methods.
  • For abstract classes we should compulsory create child class to provide implementation whereas for final class we can’t create child class.  Hence final abstract combination is illegal for classes.
  • Final class cannot contain abstract methods whereas abstract class can contain final method.
  • What is the difference between abstract and strictfp?
  • Strictfp method talks about implementation where as abstract method never talks about implementation hence abstract, strictfp combination is illegal for methods.
  • But we can declare a class with abstract and strictfp modifier simultaneously. That is abstract strictfp combination is legal for classes but illegal for methods.
  • Constructor Vs instance block
  • Both instance block and constructor will be executed automatically for every object creation but instance block 1st followed by constructor.
  • Then main objective of constructor is to perform initialization of an object.
  • Other than initialization if we want to perform any activity for every object creation we have to define that activity inside instance block.
  • Both concepts having different purposes hence replacing one concept with another concept is not possible.
  • Constructor can take arguments but instance block can’t take any arguments hence we can’t replace constructor concept with instance block.
  • Similarly we can’t replace instance block purpose with constructor.
class Test
{
    static int count = 0;
    {
        count++;  //instance block 
    }

    Test()
    {
    }

    Test(int i)
    {
    }

    public static void main(String[] args)
    {
        Test t1 = new Test();
        Test t2 = new Test(10);
        Test t3 = new Test();
        System.out.println(count);//3 
    }
}
  • What is the difference between write(100) and print(100)?
  • In the case of write(100) the corresponding character “d” will be added to the File but in the case of print(100) “100” value will be added directly to the File.
  • What is the difference between general import and static import?
  • We can use normal imports to import classes and interfaces of a package. Whenever we are using normal import we can access class and interfaces directly by their short name it is not require to use fully qualified names.
  • We can use static import to import static members of a particular class. Whenever we are using static import it is not require using class name we can access static members directly.
  • What is the difference between abstract class and abstract method?
  • If a class contain at least on abstract method then compulsory the corresponding class should be declare with abstract modifier. Because implementation is not complete and hence we can’t create object of that class.
  • Even though class doesn’t contain any abstract methods still we can declare the class as abstract that is an abstract class can contain zero no of abstract methods also.
  • Difference between Hashmap and Hashtable
  • Hashtable is synchronized while hashmap is not. So hashmap performs better where synchronization is not required.
  • Hashmap allows null keys and null values while hashtable does not.
  • Most code which deals with Hashmap interacts through the Map interface.
  • Map interface is implemented by LinkedHashMap, TreeMap etc. classes too which help to maintain a particular order of elements. So its easy to substitute TreeMap or LinkedHashMap in place of HashMap. There is no such substitute available for Hashtable. 4) Synchronization in a HashMap is easy to achieve by using Collections.synchronizedMap(myMap)
  • So in practice, Hashmap is better than Hashtable for all the use cases and should be preferred.
  • Difference between Integer.parseInt(String s) and Integer.valueOf(String s)?
  • parseInt returns primitive “int” while valueOf returns the object Integer.
  • In fact, valueOf internally does new Integer(Integer.parseInt(s))
  • An interesting function here is Integer.valueOf(int i) which converts a primitive into the corresponding object.
  • This method should be preferred for creating objects from primitive integers (instead of new Integer (i)) because it caches the object corresponding to the primitive
  • Not all numbers are guaranteed to be cached, but the frequently used ones are cached.
  • This can result in significant savings in object creation.

The flutter tutorial  is a website that bring you the latest and amazing resources of code. All the languages codes are included in this website. The languages like flutter, android, java,kotlin etc.with the help of this languages any user can develop the beautiful application

For more information about Flutter. visit www.fluttertutorial.in