Question
Q1 Do as Directed. (Each question will have 1 mark) (i) What will be output of the following code? int i = 0; while (i
Q1
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:
Q2
Write a program in Java using Nested For Loop to print Diamond star pattern. * * * * * * * * * * * * * * * Provide a screenshot of your work.
Q3
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. Q4 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.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started