group 1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

INSTITUTE OF ACCOUNTANCY ARUSHA

GROUP ASSIGNMENT:

PROGRAM NAME: BCS II

MODULE NAME: OBJECT-ORIENTED PROGRAMMING

MODULE CODE: ITU 07322

SEMESTER: ONE

ACADEMIC YEAR: 2024/25

GROUP NUMBER: 01

FACILITATOR: MBISE (MR KAANAEL)


S/N NAMES REG NUMBER SIGNATURE
1 JAMES FRANCIS BCS-01-0164-2023
2 GEWE PETER BCS-01-0157-2023

3 LUGATA NJILE BCS-01-0076-2023


4 JOSEPH BUNDALA BCS-01-0115-2023
5 AMOS LUSWETULA DEUS BCS-01-0120-2023
6 STEPHEN ROBINSON BCS-01-0160-2023
7 SIXMUNDY FRANCIS BCS-01-0005-2023
8 JACKSON LYMO BCS-01-0141-2023
9 KENNEDY KATARAMA BCS-01-0159-2023
10 DAMAS MAIGE BCS-01-0116-2023
Question One

Explain how Java has grown to be one of the most widely used programming
languages for creating desktop, web, and mobile applications.

The java grown to be one of the most widely used programming


languages for creating desktop, web, and mobile application due to the following
factors.

It is object-oriented: all the things in java act as an object and it is easily


extended as object model based

It is platform-independent: unlike others java does not get compiled


into platform specific machines. Rather it gets compiled into platform independent
bytecode. This bytecode is distributed over the webs and the Java Virtual Machine
(JVM).

It is secure: java come with security features that helps us to develop


virus free and other program in security form also make it a robust language for
large-scale application.

Versatility: java supports the development of diverse applications


include desktop, web, mobile and enterprise-level solution. Also create framework
like spring for web and enterprise applications, Android SDK for mobile
development.
Question Two

(a) Describe arrays in detail and their role in Java programming language.

An array is a collection of variables (called elements or components)


containing values that all have the same type stored in contiguous memory
location. The following are the roles of array in java programming.

Used in Algorithms: Arrays are used extensively in sorting,


searching, and matrix operator.

Foundational Data structure: Many advanced data structures


example (list, stacks) is built on arrays.

Indexing: Element are accessible via Zero -based indexing, making


data manipulation straightforward.

Data organization: Arrays help store and manage large amounts


of data efficiently.

Fixed size: Arrays have fixed size which makes them predictable
and easily to iterate over

(b) With examples, discuss the types of arrays in Java.


Arrays have many types most of its types are.
Single-Dimensional Arrays: these are the arrays which have
only one dimension. Example initialized single-dimensional array
Int [] array = {2,3,4};
Mult-Dimensional Arrays: these are arrays with more than
one dimension like matrix. Example initialized Double-dimensional array
Int [] [] matrix = {
{1, 2, 3},
{1, 2, 3}
};
Jagged Arrays: these are arrays: with varying row sizes.
Example initialized Jagged array
Int [] [] jagged = {
{1, 2},
{3, 4, 5}
};
(c) A Java array is initialized as double [] list = {17, 19, 23, 60, 58, 90};
i. Write an application that calculates and displays the sum and average of all
elements in the array list.
Public class SumAndAverage {
Public static void main (String[] args) {
double[] list = {17, 19, 23, 60, 58, 90};
double sum = 0;
for(double num: list) {
sum +=num;
}
Double average = (double) sum / array.length;
System.out.println(“sum is: ”+sum);
System.out.println(“average is: ”+average);
}
}
ii. Write an application that displays the smallest and largest elements in the
double array list.
Public class LargestSmallestElement {
Public static void main (String[] args) {
float[] numbers = {17, 19, 23, 60, 58, 90};
float max = numbers[0];
float min = numbers[0];
for (float num: numbers) {
if (number > max) max = number;
if (number > min) min = number;
}

System.out.println(“Largest is: ”+max);


System.out.println(“Smallest is: ”+min);
}
}
REFERENCES.
NARESHI technologies [ONLINE AVAILABLE AT]
https://www.nareshit.com/array in java programming. /

You might also like