ProgUseJava SampleExam-----PTJ_(01-07)(reference answer参考答案)

 

INTERNATIONAL DIPLOMA IN COMPUTER STUDIES

 

PROGRAMMING TECHNIQUES USING JAVA

 

 

 

Registration No:

 

 

 

 

 

 

 

-

 

 

 

 

 

 

 

-

 

 

 

 

 

 

   Student No:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

                                         DURATION: 3 Hours and 10 Minutes Reading Time

 

 

INSTRUCTIONS:

 

ü         Students are reminded to write their own Registration and Student Number clearly on Question Paper and All Pages of Answer Scripts.

 

ü                  Students are reminded to read the questions carefully.

 

ü                  No reference material of any kind may be taken in the examination.

 

ü         Students must attempt ALL questions.

           

ü                  There are 4 pages altogether.

 

 

QUESTION NO

MAXIMUM MARKS

MARKS OBTAINED

Part – I ( 1 to 10)

10 x 2 = 20

 

Part – II ( 1 to 4 )

4 x 20 = 80

 

Total

100

 


Part – I (20 Marks)

 

1)                  A set of instructions combined into a file is called a ____________ .

 

A)    Program             B)  Code                  C)  Machine code       D)  None of them

 

2)                  Which of the following allows a user to focus on the program logic without worrying about the detailed rules of a particular programming language?

 

A)    Compiler            B)  Interpreter          C)  Pseudocode 伪码        D)  Assembler

 

3)                  The program that translates source code programs into computer language is known as _____________ .

 

A)    Compiler            B)  Assembler          C)  Interpreter            D)  None of them

 

4)                  Which of the following is NOT a high level language?

 

A)    Assembly           B)  C                        C)  Fortran                D)  Pascal

 

5)                  Which of the following is NOT an object-oriented programming language?

 

A)    C++                   B)  LISP                  C)  Java                     D)  PERL 

 

6)                  The records in a _____________ file are organized serially, but the records in the file may be in ordered or unordered.

 

A)    Serial                  B)  Sequential           C)  Index Sequential   D)  Direct Access

 

7)                  A(n) __________ is a detailed, step-by-step solution to a problem.

 

A)    Algorithm          B)  Pseudocode       C)  Methodology        D) Program

 

8)                  A name for a constant value is called a _____________ .

 

A)    Literal                 B)  Variable              C)  String                   D) Expression

 

9)                  Java is what is know as a _____________ language.

 

A)    Weakly typed    B)  Strongly typed   C)  Both A and B      D)  Neither A nor B

 

10)              To run a compiled Java program, the machine must have _____________ installed.

 

A)    Java virtual machine                              B)  Java compiler

C)    Java bytecode                                      D)  A browser

 

 

 

Part – II (80 Marks)

 

Question 1 (20 Marks)

 

a)                  What do you understand by the term “Computer Program”?                              [4 Marks]

 

Reference:  

in order to execute a specific task , a computer can only work from a file which a set of instructions combined into , this file is called computer program.

 

b)                  Distinguish between Low level and High level language.                                      [4 Marks]

 

Reference:

1) The low level language ,for example ,‘machine code ’which is  represented in binary’assembly language’which is represented in instruction and labelsis very difficult  for programmer , but they are efficiency at run time

2) the high level language ,for example ,’c’, ‘java’, is very powerful and easy for programmer to understand and write

 

c)                  Differentiate between Compiler and Interpreter.                                                 [4 Marks]

Reference:

1) interpreter is a program that reads and executes instructions writer in the form of a program.

2) compiler is the program that translates source code programs into computer language

 

                                                                                                                                                     

d)                  Describe the uses of the Machine Code by the machine.                                      [4 Marks]

Reference:

Machine coding is one-for-one language. A great many simple instructions is executed by the machine. It identify the data it has 0 and 1.

 

e)                  List some advantages and disadvantages of Machine language.                             [4 Marks]   

Reference:

languages

Advantages

Disadvantages

Machine

Efficiency at run time and simplicity of instructions

Difficult to learn , time consuming to write and very difficult to amend

 

Question 2 (20 Marks)

 

a)                  Explain the uses of Macros and Subroutine in programming.                               [4 Marks]

Reference:

1)macros is like a formula , a symbol, it represent a computed data.

2)Subroutine is a piece of program code that represents or computes a value

 

b)                  Outline the  requirements of a software design method.                                       [6 Marks]

Reference:

The requirements of a software design method may be summarized as follows:

1) to enable correct  programs to be produced

2) to faciliatate the organized control of software projects

3) to facilitate  the handling of large and/or complex projects

4) to enable systematic methods to be applied vigorously by trained personnel

5) to provide a method that is “workable” within the intellectual limitations of an average programmer

6) to afford techniques that can be taught and does not rely on inspiration or perspiration

 

c)                  List the four different types of file organization.                                                    [4 Marks]

Reference:

The organization of records in a file can be one of four different types.

1) Serial File: The order of records in the serial file is according to the time when the data was generated.

2) Sequential File: Here records are in sequence of one or more key fields.

3) Indexed Sequential File: This holds the key field from each record in sorted sequence; along with the address of the corresponding record. like that in a book.

4) Direct Access File: For quick direct access, each record goes at an address generated by applying a formula to the record key.

 

d)                  What is Decision Table? What are the basic elements of a decision table?             [6 Marks]

Reference:

A Decision Table is a table showing the various actions to be taken for different combinations of conditions.  The upper rows of the table specify the variables or conditions to be evaluated and the lower rows specify the corresponding action to be taken when a condition or a set of conditions is satisfied.

There are 4 basic elements in a decision table.  They are:

1) The Condition Stub

2) The Condition Entries

3) The Action Stub

4) The Action Entries

 

Question 3 (20 Marks)

a)                  Describe each of the following approaches to program design checking:

 

i)                    Dry Run

ii)                   Walk-through                                                                                    [2 x 5 Marks]

Reference:

1) Dry Run:   This technique involves the working through of a piece of design code from your desk: the checker (often the programmer) pretends to be the computer carrying out the program. 

2) The basic idea is for the author of the design to expose it to a collection of his colleagues for "group criticism".  In its most formal form, an invitation is sent to a number of interested persons, not including management personnel, together with copies of the relevant documents.

 

b)                  What is meant by an “Expression” in programming? Give examples.                     [6 Marks]

Reference:

An expression is a piece of program code that represents or computes a value. An expression can be a literal, a variable, a function call, or several of these things combined with operators such as + and >. For example,(A+B)*C

 

c)                  What do you understand by “Egoless Programming”?                                          [4 Marks]

Reference:

It is most important that individual team members are encouraged to do this right from the start.  Unfortunately, many people find this difficult to accept, but it is worth persevering with.  Much has been written about "Egoless" programming, meaning "this is not my program but our program", and this approach may encourage closer inspection of work by all concerned. 

 

Question 4 (20 Marks)

 

a)                  Explain the concept of object-oriented programming.                                           [4 Marks]

Reference:

Object-Oriented Programming (OOP) represents an attempt to make programs more closely model the way people think about and deal with the world. a programmer who is faced with some problem find objects -- entities that have behaviors, that hold information, and that can interact with one another. Programming consists of designing a set of objects that somehow model the problem at hand. Software objects in the program can represent real or abstract entities in the problem domain.

 

b)                  What are “objects” and “classes”? Give examples.                                               [6 Marks]

Reference:

a class can contain properties (variables) and methods (subroutines). A class is a kind of factory for constructing objects. objects belong to classes. An object that belongs to a class is said to be an instance of that class. Objects are created and destroyed as the program runs, and there can be many objects with the same structure, if they are created using the same

In the following example ,student  is the class we defined, stu is an object of the class student.

class.

Class student{

String name;

double t1,t2,t3;

double getAverage(){

return (t1+t2+t3)/3;

}

}

class aaa{

Public static void main(String[] args

{ student   stu=new student();

su.name=”zhang san”;

System.out.println(stu.name);

}

}

c) in the purpose of Constructor and Destructor in object-oriented programming.

                                                                                                                                       [4 Marks]

Reference:

Object types(对象类型) in Java are very different from the primitive types(原始). Simply declaring a variable whose type is given as a class does not automatically create an object of that class. Objects must be explicitly constructed(对象必须显式地被构造) we use a constructor to construct an object. In the  process of constructing, constructor ask the computer, first(首先), to find some unused memory in the heap that can be used to hold the object(在堆中找出还未被使用的能装载对象大小的内存) and, second, to fill in the object's instance variables(其次,初始化对象中的变量).

 

c)                  Explain the following terms related to object-oriented programming:

 

i)                    Attribute

ii)                   Instance

iii)                 Method                                                                                             [3 x 2 Marks]

Reference:

1) Attribute  is properties that a class can contain, usually in program, it represents by all kinds of variables.

2) Instance is specific, an object that belongs to a class is said to be  an instance of that class.

3) Method is represented by subroutines in java program,  a class, represents a entiey, has behaviors, can interact with one another.

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值