by Dinesh Thakur Category: Classes

Java ArrayList class is a part of unified architecture (collection framework) interfaces are present in java.util package and used when we want to change the array size when your Java program run. You know that arrays are that they're fixed size that must be specified the number of elements when the array created. How to add elements values to an array in java that filled? It's an easy way to create a more extensive array, and all its elements are copied from the (smaller) source array to the (broader) target array, with the remaining space for new elements. It's an alternative is to use the ArrayList whose size can change frequently. An instance of Java ArrayList class contains an array that dynamically increased as required so that it relaxes the programmer from the burden of doing this.



 
by Dinesh Thakur Category: Classes

Generics are used to enforce type-safety in a program. A type-safe program does not have compilation and run-time errors that can result from using incorrect data types.



 
by Dinesh Thakur Category: Classes

The collections framework consists of several interfaces and classes (in the java.util package) that define data structures to store data, search for and retrieve data, and perform other operations on a collection efficiently. An example is the ArrayList class.



 
by Dinesh Thakur Category: Classes

Singleton Class in Java: A given class whose object (an instance of the class) is instantiated only once in JVM (Java Virtual Machine) and that only global instance of an object of the class used for every access. Such objects are mainly immutable.

 
by Dinesh Thakur Category: Classes

Java provides four levels of protection for methods and instance variables: public, private, protected and package. Before applying protection levels to a program, one should know what each form means and understand the fundamental relationships that a method or variable within a class can have to the other classes in the system.

 
by Dinesh Thakur Category: Classes

Super-class constructors cannot be overridden as the constructors have the same name as their class. To be able to access a constructor in a sub-class with the same number and data type of arguments as in the super-class, it must be defined in the sub-class itself. When constructors are defined in a sub-class, the corresponding super-class constructors are called during the creation of objects of that sub-class. This ensures that the initialization of inherited parts of the objects takes place similar to the way the super-class initializes its objects. Thus, defining constructors explicitly in the sub-class will override or overload super-class constructors.



 
by Dinesh Thakur Category: Classes

Constructor methods initialize new objects when they are created. Unlike regular methods, constructor methods cannot be called directly. They are called automatically when a new object is created. When an object is created in Java using the keyword new the following things happen:

 
by Dinesh Thakur Category: Classes

Apart from class and instance variables, Java also has class and instance methods. The differences between the two types of method are analogous to the differences between class and instance variables. Class methods are available to any instance of the class itself and can be made available to other classes. Therefore, some class methods can be used anywhere, regardless of whether an instance of the class exists or not.

 
by Dinesh Thakur Category: Classes

There are mainly two ways of passing arguments to methods:

• Pass by value

• Pass by reference

Java directly supports passing by value; however, passing by reference will be accessible through reference objects.

 
by Dinesh Thakur Category: Classes

Classes are the fundamental building blocks of any object-oriented language.

A class describes the data and behaviour associated with instances of that class. When a class is instantiated, an object is created: this object has properties and behaviour similar to other instances of the same class. The data associated with a class or object is stored in variables. The behaviour associated with a class or object is implemented by means of methods. Methods are similar to the functions or procedures of procedural languages such as C or Pascal.

 
by Dinesh Thakur Category: Classes

• Code reusability New objects can be derived from old objects, allowing for improvement and refinement of the code at each stage and also preserving parts of the code for other programs. This is used to develop many class libraries using class codes that have already been written, for example, Microsoft Foundation Classes (MFC).

 
by Dinesh Thakur Category: Classes

Now that we know the basic concepts in OOP, we are in a position to compare it with classical procedure oriented programming.

 
by Dinesh Thakur Category: Classes

In early days, programs were collections of procedures acting on data. A procedure is defined as a collection of instructions executed in sequential order. Data were independent of the procedures and programmers have to keep track of functions and the way they modify data. Structured programming is a simpler way to tackle this situation.

 
by Dinesh Thakur Category: Classes

Objects and classes are the building blocks of OOP. To understand OOP, first we have to know what objects and classes are.

 
by Dinesh Thakur Category: Classes
 

Page 1 of 3



About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Related Articles