Introduction
Object-Oriented Programming (OOP) is used to describe a programming approach that supported objects and categories. Object-Oriented Programming is extremely useful for “beginner programmers” and sometimes for intermediates. Object-oriented programming (OOP) may be a programming paradigm supported the thought of “objects”, which may contain data and code: data within the form of fields (often referred to as attributes or properties), and code, within the form of procedures. The object-oriented programming approach encourages:
Background
Since the Eighties, the word ‘object’ has made its appearance bearing the relevance in the field of programming languages. Most languages developed since 1990 having object-oriented options. Learning object-oriented programming is crucial to any or all trendy packages’ development—including mobile apps. It will safely be aforesaid that the item has been the propulsion within the programming business for an awfully very long time and can still be thus for the predictable future. As a result, nearly all programming languages, scripting languages, and application styles area units are object-oriented or object-based. It is widely accepted that object-oriented programming is the most significant and powerful means of making software package.
The Highlighted Topics are Discussed Below |
Contents:
|
A computer system is a combination of all the components required to process and store data. A computer system is composed of hardware and software. Software is classified into two types, application software, and system software. (Farrell, J. 2017).
Hardware and software contain input, processing, and output. The major computer programming languages are VB, C#, Java, C++. Compiler or software translates the source code to machine language statements. And is machine language statement is called object code.
Syntax error in the Program is called syntactical error and a logic error in a program is called logical error.
Two most common planning tools are flowcharts and pseudocode.
Repeating or looping concepts in a program helps to execute one or more statements up to a desired number of times.
The Highlighted Topics are Discussed Below |
Contents:
|
A ‘variable declaration’ gives assurance to the compiler that the existence of the variable. The data type defines that operations will safely be performed to create, transform, and use the variable in another computation. Here we can mention some of the data types like-
Variables are case sensitive and naming conventions are Camel casing, Pascal casing, Hungarian notation, Snake casing, Mixed case without underscores, Kebob case.
Different arithmetic operators can be used + (addition), – (subtraction), * (multiplication), / (division) in program code.
Two types of constants are used in code, ‘Numeric Constant’ and ‘String Constant’.
Numeric Constant | Number (ex: 1,2,3,4,5 etc) |
String Constant | Number and character (ex: 1,2,3,4 and A, B, C, D etc) |
Introduction of Java:
I/O is used to perform input and output operations. Input expect from the user and output is the value that returns to the user.
Input example:
int nextInt(int n);
Output example:
System.out.println(“Next int value: “+number+”\n”);
The Highlighted Topics are Discussed Below |
Contents:
|
The descriptive name for logically snarled program statement is spaghetti code.
Disadvantages of unstructured spaghetti code:
Structure:
A structure is based on program logic. Each structure program consists of sequence, selection, and loop. Any structured program contains any number of structures (Budd, T. 2008).
Selection structure use different relational operators as follows-
== | Equivalency |
> | Greater than |
< | Less than |
>= | Greater than equal to |
<= | Less than equal to |
!= | Not equal to |
&& | Logical AND |
|| | Logical OR |
| | Logical NOT |
Below is the syntax of case structure in Java
switch(expression) {
case value :
break; // optional
case value :
break; // optional
default : // Optional
}
The Highlighted Topics are Discussed Below |
Contents:
|
Loop is a control variable and which is defined for the transformer stage. Loop condition determines whether the program will run or break. It repeats a set of actions while a condition remains true. There are three different loop conditions such as ‘while loop’, ‘Do-while’, and ‘for loop’ (Farrell, J. 2017).
While loop: It evaluates the statement within the parenthesis. If the process-condition evaluates false, the loop terminates.
Syntax:
while (condition) {
// body of the loop
}
Do-while loop: It is similar to while loop. Do-while loop is called ‘post-test loop’, because the condition is tested after the loop’s body has executed.
Syntax:
do {
statement(s);
} while (condition);
For loop:This loop is a repetition management structure that permits expeditiously to write a loop that has to execute a particular range of times.
Syntax:
for ( init; condition; increment ) {
statement(s);
}
Statement endif, if-then-else, endwhile is end structure statement.
Structure-programming is used for clarity, professionalism, efficiency, maintenance, and modularity.
The Highlighted Topics are Discussed Below
|
Contents:
|
Array is a collection of data elements. There are two types of data arrays- single dimensional array and multi-dimensional array. Single dimensional array stores data in a linear form and multi-dimensional array, having more than one dimension, stores data in tabular format. (Kiong, D., Ashok, S.,& Poo, D. 2008).
Single Dimensional Array: Example: intArray[0] = 1;
Multi Dimensional Array: Example: int a[] [][]= new int[2][3][4];
Advantages of array:
Array in a java program involves three distinct steps.
Syntax
<elementType>[] <arrayName>;
Syntax
arrayname = new dataType[]
Syntax
[] = {};
Java Array is the most common type of data-structure which contains similar types of data value. The data items place in the array are called elements and the first element in the array starts with the index zero.
Single dimensional array declares in java:
Multi-dimensional array declares in java:
Multi-dimensional array can be accessed by using loop.
The Highlighted Topics are Discussed Below |
Contents:
|
Java source is named as *.java and byte is code named as *.class. Java source file contains a single public class or interface. Each class is placed in a separate file. Java source files have the following orderings: package and import statements, beginning comments, class, and interface declarations (Downey, A. B. & Mayfield, C. 2019).
The header of all source files is as follows – title, version, date in mm/dd/yy, and copyright information.
Java source code guidelines are as follows:
Declaration:
Naming convention standards:
Software Testing is a method to check whether the actual program or application matches the expected requirements or not and to ensure that the program or application is Defect free. Testing steps are:
The Highlighted Topics are Discussed Below |
Contents:
|
Modularization of code is the process of dividing software into separate subcodes. A module is a separate software code. It can often be used within different of applications and functions with other components of the system.
Benefits of modularization
Abstraction is the process of paying attention to important properties while ignoring inessential details.
Java Modularization
Syntax:
Modifier returnValueType methodName(list of parameters) { //Method body; }
Example of using local variable
public class HelloApp
{ public static void main(String[] args) { String helloMessage; helloMessage = “Hello, World!”; System.out.println(helloMessage); } } |
The Highlighted Topics are Discussed Below |
Contents:
|
ArrayList is a part collection of frameworks and found in ‘java.util package’. Standard java arrays are of a fixed length. Array list supports dynamic arrays and can grow if needed.
ArrayList constructor
ArrayList()
ArrayList(Collection c) ArrayList(int capacity) |
Some common operations in arrayList
An Iterator is an object that can be used to iterate through ArrayList. Method declaration is done by Iterator:
Example of Iterator use:
Iterator itr = al.iterator();
Object is an instance of a class. It is real world physical entity. It can be created many times as per requirements. It allocates memory.
Example:
Object name “myObj”
public class MyClass {
int a = 50;
public static void main(String[] args) { MyClass myObj = new MyClass(); System.out.println(myObj.a); } } |
Class is a blueprint or template of object which is created. It is a logical entity. It is declared one time. Class doesn’t allocate memory when it is created.
Example:
Class name “MyClass”
public class MyClass {
int x = 5; }
|
Four types of access-specifiers are available in Java:
The Highlighted Topics are Discussed Below |
Contents:
|
Constructoris a block of codes that is used in java as a special method. Constructor is called when an instance of the class is created. It establishes an object. There are two types of constructor is used in Java.
Default Constructor doesn’t have any parameter. It provides the default values to the object like 0, null etc. depending on type.
Syntax:
<class_name>(){}
Parameterized constructor has a specific number of parameters. It is used to provide different values to different objects.
Syntax:
<class_name>(parameter_list){}
The method Destructor is called when an instance of a class is destroyed. The main goal of the destructor is to free some memory space and also to clean up resources like the closing of open files, closing of database connections, closing network resources, etc, (Niemeyer, P.& Knudsen, J. 2005).
Syntax:
Class Object
{
protected void finalize()
{
//statements like closure of database connection
}
}
Getter and Setter are two methods that are used for retrieving and updating the value of a variable.
get – getter method to get the value.
set – setter method to set the value.
Syntax:
getXxxx()
setXxxx()
The Highlighted Topics are Discussed Below |
Contents:
|
Encapsulation: Wrapping up of data into a single unit is called encapsulation.
Advantages of encapsulation:
Polymorphism:Poly means ‘many’ and morphism means ‘form’. One name having many forms is called polymorphism. Polymorphism has the ability to display a message in more than one form. An example of polymorphism is – a person at the same time can have different characteristics. (Cornell, G.&Horstmann, C. S. 2008).
Polymorphism is two types:
Method overriding is an example of run-time polymorphism and method overloading is an example of compile-time polymorphism.
Inheritance:It is important in OOP(Object Oriented Programming). It allows one class to inherit the features of another class.
Important features of Inheritance are:
Syntax:
class derived-class extends basis class
{ //method and fields } |
The Highlighted Topics are Discussed Below |
Contents:
|
An array is a collection of similar data types. An array of objects is created, based on the ‘Object’ class. One name is used to refer to the entire group. The array elements store the location of the reference variables of the object. Array is a dynamically created object. Once the array object is defined, it is mandatory to initialize it with values. Using the ‘sort’ method, the objects of an array can also be sorted. An array of objects is created just like an array of primitive type data items in the following way (Flanagan, D. 2002).
Class_name [] objArray;
Advantages of array:
Conclusion
Java is an object-oriented and class-based programming language. It offers a real-time possibility. It allows the definition and implementation of generic abstractions. Java is an IDE (Integrated Development Environment). It stands on class and object.
Work Cited