IT 401
|
Pg. 01 |
|
Question One |
|
|
|
|
Assignment 3
Deadline: Saturday Dec/03/2017 @ 23:59
[Total Mark for this Assignment is 20/4 = 5 ]
Business Computer Languages IT 401
College of Computing and Informatics
|
|
|
|
|
|
|
|
Question One
4 Marks
Learning Outcome(s): LO2
Instructors: Students will have logical understandability for Java Iteration concepts.
Do as Directed. (Each question will have 1 mark)
(i) What will be output of the following code?
int i = 0;
while (i != 9)
{
System.out.println(" " + i);
i = i + 2;
}
Answer:
(ii) What will be the output of the following code?
int i = 1;
int sum = 0;
while (i <= 11)
{
sum = sum + i;
i++;
}
System.out.println("The value of sum is " + sum);
System.out.println("The loop will continue " + i + “ times.”);
Answer:
(iii) How many times does the following Java code display "Java Program" output?
for (int i = 0; i < 10; i++);{System.out.println(" Java Program ");}
Answer:
(iv) In the following code, How many times the output “My Name” will be print?
int p;int q;for (p = 0; p <= 9; p++){for (q = p; q < 5; q++){System.out.println("My Name");if (q == 2){q = 6;}}}
Answer:
Question Two
8 Marks
Learning Outcome(s): LO3
Instructors: Students will learn the practical knowledge of Nested For Loop in Java.
Write a program in Java using “Nested For” Loop to print Diamond star pattern.
*
* *
* * *
* * * *
* * * * *
Provide a screenshot of your work.
Question Three
4 Marks
Learning Outcome(s): LO2
Instructors: Students can understand array and array list.
Write a short notes on Following topics. (each question will have 1 mark)
a. What is an Array?
b. How do declare array in various format?
c. Define Array List.
d. Give an example for add and remove array element.
Question Four
4 Marks
Learning Outcome(s): LO3
Instructors: Students can understand Array list function.
Write a Java Program to display following output using Array List.
Before 2015 Saudi Electronic University Branch: 0
After 2015: 7
Number of Branch: [Dammam, Tabuk, Jeddah, Madinah, Al Qassim, Abha, Al Jouf]
Number of Branch after deletions: 5
Total of Branch: [Dammam, Tabuk, Madinah, Al Qassim, Al Jouf]
Provide a screenshot of your work.