• No results found

Ics201-Final Form B.doc

N/A
N/A
Protected

Academic year: 2020

Share "Ics201-Final Form B.doc"

Copied!
12
0
0

Loading.... (view fulltext now)

Full text

(1)

Kingdom of Saudi Arabia Ministry of Higher Education

University of Hail

College of Computer Science and Engineering Department of Computer Science and Software

Engineering

ةيدوعسلا ةيبرعلا +ةكلمملا يلاعلا ميلعتلا ةرازو

لئاح +ةعماج يللآا بساحلا ةسدنهو مولع +ةيلك تايجمربلا ةسدنهو بساحلا مولع مسق

Final Exam in: Intro to Computer Science / ICS201

First Semester 2013/2014

(Including cover page this exam booklet contains 12 pages)

Exam Date: 08.01.14 Exam Duration: 120 minutes

Student Name:___________ Student ID:__________

Find your section from the table below:

Instructor Name Day Day/Time Section Check

Mrs. Nesrean Thalji (Coordinator) UTR 0800 - 0850 101

Mrs. shahana a anjum UTR 1000 - 1050 103

Mrs. Hula M Al-khassawneh UTR 1100 - 1150 104

Mrs. ibtesam salah saleh UTR 1200 - 1250 105

Mrs. Ibtesam H Hamed MW 1100 - 1220 106

Instructions:

1. Including this cover page, this exam booklet contains 12 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.

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

 Mobile use. ةلاقنلا فتاوهلا مادختسا 

 Questions after the first quarter of the exam time.

 ةدم نم لولأا عبرلا دعب ةلئسلأا

ناحتملاا  Leaving the exam room for any reason. ببس يلأ ةعاقلا ةرداغم 

 Borrowing tools from other students نيرخآ بلاط نم تاودلأا ةراعتسا 

Good

Luck!

Part I: (13

marks)

Max Score Student Score

Part I 13

Part II 17

Part III 5

(2)

Answer the following question put either True[

] or False[

]:

1 The more pixels on a screen, the greater the screen resolution.

2 Variable Hiding happens when a variable of a class has a same name (type maybe different) as a superclass variable.

3 When a method in a derived class has a different signature from the method in the base class, that is Method overriding.

4

Given the following method header in a base case: public void getName()

The following method header is valid in a derived class: private void getName()

5 In class diagram the top section contains data specification for the class.

6 A sharp (#) indicates protected access.

7 In a model view controller pattern, the view part is the output part.

8 Patterns are requirements, not guides.

9 Exception handling should be used only for problems that occur infrequently.

10 Error-handling code makes the program difficult to read, modify, maintain, and debug .

11 A throw statement is similar to a method call.

12 The catch blocks are examined in order when an exception is thrown in a try block

13 In an event-driven program, the next thing that happens depends on the next instruction.

Part II: (17 Marks)

(3)

answers:-1 2 3 4 5 6 7 8 9 10

11 12 13 14 15 16 17

1. Given the following interface declaration:

interface Communicate{ int LOUD = 0; void talk(); void listen(); }

Which one of the following code segments is right?

A. public class A implements Communicate {

public void talk(){ System.out.print(“A talk”); } B. public class B implements Communicate {

public void talk(){ System.out.print(“ A talk”); }

public void listen( String s){ System.out.print(“B talk “+ S);} C. public class A implements Communicate {

public void talk(){ System.out.print(“IA talk”);} public void listen( ){ System.out.print(“B talk “);} D. public class A implements Communicate {

public int talk(){ return 20;}

public void listen( ){ System.out.print(“B talk “);}

2. Which of the following is a correct interface?

A. interface A { void print() { }; }

B. abstract interface A { print(); }

C. abstract interface A { abstract void print() { };}

D. interface A { void print();}

3. Suppose

A is an interface, B is a concrete class with a default constructor

(4)

A. A a = new A();

B. A a = new B();

C. B b = new A();

4.

What is the output of the following program? class Outer {

private int myself = 0; protected int friends = 0; class Inner {

public void invite() { friends++;

myself++; } } public void test() {

Inner event = new Inner(); event.invite();

System.out.println("Friends: " + friends); System.out.println("Myself: " +

myself); }}

public class InnerExample {

public static void main(String[] args) { Outer party = new Outer();

party.test(); }

}

A. Friends: 0

Myself: 0

B. Friends: 1

Myself: 1

C. Myself: 1

Friends: 1

(5)

A. We have cast Circle to the type Shape. B. We have cast shape to the type Circle. C. Downcasting.

D. There is no casting.

6. Which of the following is true about Abstract Class:

A. It cannot be private.

B. It has at least one abstract method.

C. It must have the modifier abstract included in its class heading. D. All the above.

7. If the method definition is associated with its call when the method is

invoked (at run time), that is called:

A. Early binding. B. Late binding. C. Binding. D. A and B.

8. There are three main programming mechanisms that constitute

object-oriented programming (OOP) :

A. Encapsulation, Inheritance and Polymorphism. B. Upcassting , downcasting, and binding. C. Inheritance, casting, and polymorphisim. D. Encapsulation, Inheritance, and binding.

9. It is a windowing system that interacts with the user.

A. AWT

B. GUI

C. showMessageDialog. D. A and B

(6)

A. listener, event. B. event, listener. C. firing, action. D. action, firing.

11.A manager places the components that are added to a JFrame object

into five regions.

A. BorderLayout. B. FlowLayout. C. GridLayout D. Setlayout.

12.A class diagram is divided up into ……… sections

A. 2

B. 3 C. 4 D. 5

13.Sign indicates public access.

A. minus (-)

B. plus (+) C. sharp (#) D. tilde (~)

14.Print all the elements available in list “arrlist”.

A. for (Integer number ; arrlist) {System.out.println("Number = “)}

B. for (Integer number : arrlist) {System.out.println("Number = " + number);} C. All the above

D. Not all the above

(7)

B. Private. C. Public D. Final

16.One of these statement is

legal:-A. public Pair(T first, T second)

B. public Pair<T>()

C. public class GEx<T> extends Exception D. T object = new T();

17.The type plugged in for a type parameter must always be

A. int.

B. a reference type. C. char.

D. double.

(8)

A. Write a recursive java code function to compute the sum = 1+2+3+4+...

+n (3 marks)

………

………

………

………

………

………

B. Show the solution of f(4). (2 marks)

………

………

………

………

………

(9)

Part IV :- ( 5 marks)

Complete the following

code:-// write two important import statements.

……… (0.5 mark)

……… (0.5 mark)

import java.awt.event.ActionListener;

import java.awt.event.ActionEvent;

public class MessageDialogExample {

public static void main(String[] args) {

// write the code that display figure 1.

………..…… (0.5 mark)

// write the code that display figure 2.

………..…… (0.5 mark)

(10)

………..…… (0.5 mark)

// create frame object with name firstWindow as figure 4.

………..…… (0.5 mark)

// set the size of firstWindow to be 300, 200.

………..…… (0.5 mark)

firstWindow.setDefaultCloseOperation( JFrame.DO_NOTHING_ON_CLOSE);

// create button object with name endButton as figure 4.

………..…… (0.5 mark)

EndingListener buttonEar = new EndingListener();

endButton.addActionListener(buttonEar);

// add the button to the figure 4

………..…… (0.5 mark)

firstWindow.setVisible(true);

} }

class EndingListener implements ActionListener

{

public void actionPerformed(ActionEvent e)

{

// write the code for the button such that it close/terminate the program.

………..…… (0.5 mark)

}

(11)

Part V: (5 marks)

A. Give one difference between array and arraylist.

( 1 mark)

………

………

B. Examine the following code: (1 mark)

ArrayList<String> list = new ArrayList<String>() ; list.add( "Andy" );

list.add( "Bart" ); list.add( "Carl" ); list.add( "Doug" ); list.add( "Elmo" );

(12)

code

output

System.out.print(list.size());

System.out.println(list.indexOf("Carl"))

C. Write a declaration that would be appropriate for a list that is

expected to contain integers. ( 1 mark)

………

………

D. Suppose you have the following generic class definition.

public class Box<T>

{

private T data ;

public void setData(T newData) {

data = newData ; }

}

1- Write a getData() method to get data value. (1 mark)

………

(13)

………

………

2- Write a creation of obj1 of the generic class Box using String as

parameter. (1 mark)

………

………

Instructor signature ___________________

References

Related documents

Adverse Event Surveillance – – Public Health Public Health Agency of Canada. Agency

compass.init init (); (); // start accelerometer and magnetometer // start accelerometer and

The OpenStage 30T/40/40G/40T always requires a local power supply (SMPS mains adapter, must be ordered separately) if an OpenStage Busy Lamp Field 40 is connected.. The PNOTE

Figure 44: Contour plot of horizontal instantaneous velocity for Libeccio wind simulation, at three different horizontal planes: (A) sea surface, (B) three meters under sea surface,

When evaluating web benefit portal vendors, you should consider how quickly a client and their employees can access their data.. Some vendors can take weeks to complete the set

In addition, CSIM also provides portfolio management for ThomasPartners Strategies, which invests primarily in dividend-paying stocks and fixed income investments, and pooled

&#34;Discrete Size and Shape Optimization of Truss Structures Based on Job Search Inspired Strategy and Genetic Operations&#34;, Periodica Polytechnica Civil Engineering, 64(3),

NIBS, Non-inv asive brain stimulation; atDCS, anodal transcranial direct current stimulation; rTMS, repetitive transcranial magnetic stimulation; AD, Alzheimer’ s disease; MCI,