[go: up one dir, main page]

0% found this document useful (0 votes)
36 views1 page

CSC2302 Test

The document contains 10 questions for a Computer Programming II exam covering topics like arrays, loops, methods, and password validation. Students are asked to write programs to generate random arrays and multiplication tables, explain 'for' loop structures, define programming terms, and demonstrate usage of packages, imports, and classes like Scanner and String. Questions also cover typecasting, array initialization, and copying array elements.

Uploaded by

ibraheemyusuf04
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views1 page

CSC2302 Test

The document contains 10 questions for a Computer Programming II exam covering topics like arrays, loops, methods, and password validation. Students are asked to write programs to generate random arrays and multiplication tables, explain 'for' loop structures, define programming terms, and demonstrate usage of packages, imports, and classes like Scanner and String. Questions also cover typecasting, array initialization, and copying array elements.

Uploaded by

ibraheemyusuf04
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

YUSUF MAITAMA SULE UNIVERSITY, KANO

FACULTY OF SCIENCE
DEPARTMENT OF COMPUTER SCIENCE
2020/2021 SECOND SEMESTER TEST – DEC 2022
CSC2302 – Computer Programming II
Attempt ALL Questions Time Allowed: 1 hour 15 mins

1. Write a program that declares an array of 100 integers, set the values of each of the
elements to a random integer less than or equals to its index. Compute and display:
a. The sum of the elements
b. The average of the elements
c. The percentages of the elements equals, below and above the computed
average.
2. Write a program that produces a multiplication table of up to 10*10. For each row of
the table, compute and display the sum of the elements concatenated with “E” for even
result and “O” otherwise. The program should finally print the sum of all the elements.
3. With the aid of suitable examples, illustrate the working of all the versions of a “for
loop” control structure of Java.
4. Prior to the advent of modern way of software development, programmers spent an
awful lot of time in coming up with just a simple software. Further to this, the outcomes
are not clear, difficult to maintain and of low quality. Explain the modern approach of
getting rid of these problems delving more into its components.
5. Briefly define the following terms:
i. Method signature
ii. Array
iii. Typecasting
iv. Variables and Reference Variables
6. Explain (with examples, where possible) the usage and importance of each of the
following as relates to java:
i. package
ii. import statement
iii. Scanner class
iv. split method of String class
7. Differentiate between implicit and explicit typecasting. (3 marks)
8. do while and while are some of the repetition control structures in Java. Give the format of
these structures and hence comment on their differences.
9. Some Websites impose certain rules for passwords. Write a program that checks whether a
string is a valid password. Suppose the password rules are as follows:
• A password must have at least 8 characters.
• A password can consists of only letters, digits and an underscore.
• A password must contain at least 2 digits.
10.
i. Define an array.
ii. Clearly explain the following statement:
int x[] = new int[10];
iii. Consider the following statement:
int x[] = {1,2,4,5,6,7};
how can the elements of array x be copied into an array say y?

You might also like