• No results found

ICS 102 Final Form B.pdf

N/A
N/A
Protected

Academic year: 2020

Share "ICS 102 Final Form B.pdf"

Copied!
6
0
0

Loading.... (view fulltext now)

Full text

(1)

Final Exam in:

Computer Programming /ICS 102 First Semester 2013/2014

(Including the cover page, this exam booklet contains six pages)

Exam Date: Wednesday, 8 Jan. 2014 Exam Duration: 120 minutes

Student Name: ………..………..………..….. S.N: ……… Student ID: …..………..………..………

Course Coordinator: Mrs. Salam Al-Bazrawi

Find your section from the table below:

Instructor Name Day/Time Section Check

Ibtesam H. Hamed UT 0800 -0850 AM 101

Ibtesam H. Hamed UT 1100 -1150 AM 102

Salam H. Al-Bazrawi RU 0900 -0950 AM 103

Salam H. Al-Bazrawi MW 1100 -1150 AM 104

Layali F. Ababseh UT 0900 -0950 AM 105

Instructions:

1. Including this cover page, this exam booklet contains 6 pages. Check if you have missing pages. 2. Any form of cheating on the examination will result in a zero grade.

3. Please write your solutions in the spaces provided on the exam. You may use the blank areas and backs of the exam pages for scratch work.

4. The following is forbidden during the exam: :يلي بم نبحتملاا ءبنثأ عنوي

 Mobile use. تلبقنلا فتاىهلا ماذختسا 

 Questions after the first quarter of the exam time. نبحتملأا ةذم نم لولأا عبرلا ذعب تلئسلأا   Leaving the exam room for any invalid reason. .ببس يلأ تعبقلا ةردبغم   Borrowing tools from other students .ثبيرخلأا ثببلبطلا نم ثاودلأا ةربعتسا 

Max Score

Student Score

Part I

Question 1

20

Question 2

5

Part II

Question 3

4

Question 4

11

Part III

Question 5

5

Total

45

Best Wishes

Kingdom of Saudi Arabia Ministry of Higher Education University of Hail

College of Computer Science and Engineering

Department of Computer Science and Software Engineering

تيدوعسلا تيبرعلا تكلوولا يلاعلا نيلعتلا ةرازو لئاح تعهاج لك ـ ي ـــ ت لع ـــ سدنهو مو ــــ حلا ت ـ سا ـــ ب للآا ـ ي ق ــ س ــ لع ن ـــ حلا مو ـ سا ـــ سدنهو ب ــــ بلا ت ــ هر ــ ج ــ ـي ـــــَّـ ثا

(2)

1. Java is ………. Language.

a a platform oriented b a procedural oriented c an object oriented

2. What is the extension of the Java program?

a .java b .txt c .class

3. Which of the following is an illegal identifier in Java?

a my_Class b my$Class c myClass

4. Choose the appropriate data type for the value: 5

a byte b Boolean c char

5. Which of the following is an illegal statement in Java?

a int i = 32.0; b double d = 45; c int i = 32;

6. Which of the following is an illegal statement in Java?

a String y = ”false” ; b Boolean y = ”false” ; c Boolean y = false ;

7. What will be the result of arithmetic expression 10+27/3*3?

a 37 b 15 c 13

8. What will be the result of arithmetic expression 31/3?

a 10.0 b 10 c 10.3

9. What is the output of the following Java code?

double x = 5.5; int y = (int)x;

System.out.println(ʺ x is ʺ + x + ʺ and y is ʺ + y);

a x is 5.5 and y is 5.5 b x is 5.5 and y is 5.0 c x is 5.5 and y is 5

10.What is the output of the following Java code?

int i= 8;

int y = 7 + - -i;

System.out.println(ʺy is ʺ + y);

a y is 14 b y is 15 c y is 16

11.What is the output of the following Java code?

double a =2.578;

System.out.printf("Start %6.2fEnd", a);

a Start 2.58End b Start2.58 End c Start 2.578End

12. To input a string value that represents a single word using Scanner class object we use the method:

a nextInt() b nextDouble () c next()

13.In the ………. Loop, the Boolean expression is checked after the loop body is executed.

a do while b while c for

Part I

(

25 Marks

)

Question 1.

(20 marks, 1 mark for each)

(3)

14.The ……….will immediately end the program as soon as it is invoked:

a exit method b break statement c continue statement

15.An array holds:

a different values of different data type

b same values of different data type

c different values of the same data type

16.What is the correct syntax to declare an array of size 10 of integer data type?

a int name[ ] = name; b int [ ] name = new int[10] ; c int name[] = new name[10];

17.Which of the following is an Access Modifier in Java?

a final b public c static

18.What is the result of the following Java code?

Student std1 = new Student ();

a Declare an object std1 of Class Student b Declare an object Student of Class std1 c Declare a method std1 of Class Student

19.What is the correct syntax to declare an integer constant named x with value 5?

a final int x = 5; b final x = 5; c static int x = 5;

20.What will be the result of arithmetic expression 10/4?

a 2.0 b 2.5 c 2

Write your answers of Question1 here:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

Question 2.

(5 marks, 1 mark for each)

Match the concepts in column

A

with their definitions in column

B,

then write your answers in the table that follows the question:

A

B

1. Hardware a. Combining the data and methods of a class into a single unit, to hide the implementation details.

2. Identifier b. The name of a variable or other item (class, method, object, etc.) defined in a program.

3. Information hiding c. An entity in a running program

4. Object d. A program that connects the byte-code of the classes needed to run a Java program.

5. Class Loader e. The electronic and mechanical parts of a computer system.

Write your answers of Question 2 here:

(4)

Part II (

15 Marks

)

Question 3.

(4 marks, 1 mark for each)

Read the following Java program carefully, then answer the questions that follow it:

class Maximum {

public int max(int a, int b) {

int result; if (a > b)

result = a; else

result = b; return result; }

public double max(int a, double b) {

double result; if (a > b)

result = a; else

result = b; return result * 2; }

}

public class Test{

public static void main(String[] args) { Maximum obj1 = new Maximum (); int x = 2, y = 5;

double z = obj1.max(x, y); double u = obj1.max(y, 1.5); System.out.println(z);

System.out.println(u); }

}

Based on the code fragment below answer following questions:

1. What is the return type of max(int a, double b) method? ………..………….………

2. What is the return type of max(int a, int b) method? ………..………….………

3. What will be the value of variable z ? ………..………….………..……..………

(5)

Question 4.

(11 marks)

In the table below, write the output for each of the following codes:

Code

Output

5 ma

rk

s

int [] b={4,6,8,10,12};

System.out.println(b.length); System.out.println(b[2]+" "+b[4]);

for(int i=0; i<b.length; i++) b[i]=b[i]-2;

System.out.println("updated elements:");

for(int j=0; j<b.length; j++) System.out.println(b[j]);

System.out.println("Done");

1 ma

rk

int x= 3; int y= 4; Boolean z;

z = (x < 3) && (y > 2); System.out.println(z); z = (x < 3) || (y > 2); System.out.println(z);

3 ma

rk

s

String x ="Java Exam"; String y="Hello All";

System.out.println(x.indexOf("J")); System.out.println(x.indexOf("Exam")); System.out.println(x.lastIndexOf("a")); System.out.println(x.charAt(7));

System.out.println(x.length()); System.out.println(y.substring(6));

2 ma

rk

int a=1; while(a<10) {

System.out.println(a); if (a == 4)

(6)

Part III (

5 Marks

)

Question 5.

(5 marks)

Write a Java code to calculate the area of the circle by creating a class named MyCircle

that contains:

 A double variable named radius.

 A default constructor.

A method named myCircleArea with one parameter (the radius) to compute and return the

area of the circle (3.14 * radius * radius).

Best wishes

Course Coordinatorsignature _________________________________________

References

Related documents

A spacious master bedroom suite with rear and side facing timber double glazed windows, pendant light point, wall mounted light points, USB power points, under floor heating

liability is assessed and the payment of Tax is made upon the income earned in previous year is known as Assessment Year.

Identified the preferences of Chelsea’s stakeholders, primarily low-income residents living on the waterfront, local government, industries, and property owners about Chelsea’s

Pˇ ri konkr´ etn´ı navrˇ zen´ e topologii bludiˇ stˇ e musel robot projet v´ıce neˇ z 50 kˇ riˇ zovatkami, neˇ z se dostal nejkratˇ s´ı cestou do c´ıle, a to i pˇ

In prior research, I noticed a lack of work that explored how trans people created and used multiple accounts and networks on social media in order to explore and present

Whilst there may be no company or voluntary provider with the same set of circumstances as Southern Cross, the factors that gave rise to its problems are still present within

This study investigates the nature of online complaints and responses by content analyzing nearly 2,000 one-star consumer-generated reviews of 86 Washington DC

NEXUS CRITERIA Not intoxicated Normal Mentation No Neurological deficits No midline neck pain No distracting injuries Met Not Met