Cs508 Collection of Old Papers

Download as pdf or txt
Download as pdf or txt
You are on page 1of 13

FINAL TERM EXAMINATION

SEMESTER FALL 2005


Total Marks: 100
CS508-Modern Programming Languages
Duration: 3 Days
http://vujannat.ning.com
BEST SITE TO HELP STUDENTS

StudentID/LoginID

Name

PVC Name/Code

Date 27-03-2006

Maximum Time Allowed: 3 Days

Please read the following instructions carefully before attempting any question:
The examination mode for the cs508 final term examination is take home examination,
which mean that you are allowed to take your examination papers to your home or
computer labs and complete it using all available resources. Followings are the instructions
for doing the take home examination.
• After taking the paper you can either go home to complete your paper or use PVC
labs.
• The duration of this take home examination is three days of the examination. i.e.
for cs508 it is till 29th of March 2006
• On third day (on the last day) upload the solved examination paper on the
assignments page of your course. You are allowed to use the lab facilities of the
campuses, books and handouts and any other references material available to you.
• The examination papers submitted after the due date will be marked as zero
• Plagiarism or cheating by the students will be dealt severely by Virtual University
therefore it is strongly recommended that you do your own work.

For Teacher’s use only


Question Q1 Q2 Q3 Q4 Q5 Total
Marks
Question No: 1 Marks: 25

Consider the following Code written in C.

int a = 0;

int f(int x, int y)


{
return (a = x + 1);
}

int g(int *x)


{
return (*x = a + 2);
}

void main()
{
double w;
w = double(a) + f(a, g(&a))/g(&a);
printf (“w is %f”, w);
}

On some different important commercial compilers, the values found for the variable w
were 5.6, 4.5, and 7.5. Furthermore, this last value changed to 2.5 when the expression to
compute w was changed to:

w = f(a, g(&a))/g(&a) + double(a);

None of this is an error by the compiler writer!

(a) Give a justification for each one of these values.


(b) Would Java have the same kind of problem? Why or why not. Justify.

Question No: 2 Marks:15

Compare C# and Java and highlight at least five differences. Then critically compare these
features and argue why one design is better than the other.

Question No: 3 Marks: 20


(a) Write a Prolog description of your family tree (based only on facts), going back to
your grandparents and including all descendents (males and females). The facts
should include the gender of a person and relationship of every person with every
other person.
(b) Write a set of rules for family relationships, including all relationships from
grandparents through two generations. Now add these to the facts of part (a), and
eliminate all the facts except the gender and parent-child relationship. You should
still be able to establish the relationship of any person with any other person in
your family.

Question No: 4 Marks: 15

Compare weak and strong typing. Argue why it is OK to have weak typing in scripting
languages but not in other general purpose languages such as Java and C++.

Question No: 5 Marks: 25

Consider the following 5 binding times:

(1) language design time


(2) program writing time
(3) compile time
(4) load time
(5) run time

Give at least one example of each of the above for the following languages:

(i) C++
(ii) Java
(iii) Javascript
(iv) PHP
(v) C#
http://vujannat.ning.com
BEST SITE TO HELP STUDENTS
FINALTERM EXAMINATION
FALL 2006 Marks: 60
CS508 - MODERN PROGRAMMING LANGUAGES Time: 120min
(Session - 1 )

StudentID/LoginID: ______________________________

Student Name: ______________________________

Center Name/Code: ______________________________

Exam Date: Monday, February 19, 2007

Please read the following instructions carefully before


attempting any of the questions:
Note: This paper is Close book and Close Handouts
1. Attempt all questions. Marks are written adjacent to each question.
2. Do not ask any questions about the contents of this examination
from anyone.
a. If you think that there is something wrong with any of the
questions, attempt it to the best of your understanding.
b. If you believe that some essential piece of information is
missing, make an appropriate assumption and use it to solve the
problem.
c. Write all steps, missing steps may lead to deduction of marks.

**WARNING: Please note that Virtual University takes serious note of


unfair means. Anyone found involved in cheating will get an `F` grade
in this course.

For Teacher's use only


Question 1 2 3 4 5 6 7 8 9 10 Total
Marks

Question No: 1 ( Marks: 2 ) - Please choose one

Java has a String class which is not exactly an array of

► Char
► Elements

► Indices

► Long

Question No: 2 ( Marks: 2 ) - Please choose one

How many string operators are in PHP?

► 2

► 3

► 4

► 10

Question No: 3 ( Marks: 2 ) - Please choose one

If you want an argument to a function to always be passed by reference, you can prepend

► Percentage sign (%) to the argument name in the function definition

► Dollar sign ($)to the argument name in the function definition

► An ampersand (&) to the argument name in the function definition

► Tilled sign (~)to the argument name in the function definition

Question No: 4 ( Marks: 2 ) - Please choose one

How many modes for the source code are in C# ?


► One

► Two

► Three

► Four

Question No: 5 ( Marks: 2 ) - Please choose one

Which chaining type is used by Prolog?

► Backward

► Forward

► Up

► Horizontal

Question No: 6 ( Marks: 10 )

What is meant by binding time? What are the five possible binding times? Explain each
briefly.

Question No: 7 ( Marks: 10 )

What are the enumeration and subrange types? Differentiate these two in points.

Question No: 8 ( Marks: 10 )

a) What is the purpose of type conversion? (5)

b) Differentiate between the implicit and explicit type conversion with respect to Java. (5)

Question No: 9 ( Marks: 10 )

a) What are interpreted and compiled languages? Give examples (5)


b) Differentiate between client side scripting and server side scripting languages? (5)

Question No: 10 ( Marks: 10 )

a) Describe the programming steps in Prolog? (5)

b) Explain the Prolog features regarding its applications in real world. (5)
WWW.vujannat.ning.Com
Connecting VU Students

CS508
Final Term Examination – Spring 2006
Time Allowed: 150 Minutes

Question No. 1 Marks : 1

A) Write a program in java script that prompts the student for his name and age. Then
displays “Hello guy”, to the student in alert box and gives him the message in message
box “U shouldn’t be a student of graduation” if his / her age>40.
(10)

B) What is the difference between javascript and PHP? (5)

Question No. 2 Marks : 3

A) Given are the statements of C# (5)

a = 15;
x = a++ + --a;

Find the value of ‘x’ by executing the given statement

(i) from left to right


(ii) from right to left

B) How we can handle Aliasing problem in JAVA? Give examples (5)


Question No. 3 Marks : 3
Convert the following code of PHP into C#

<?php
$a = array(0 => 5, 1 => 6, 2 => 7, 3 => 8, 4 => 9);
$b = $a[4];

switch ($b)
{
case 5:
echo “b equal to 5”;
break;
case 6:
echo “b equal to 6”;
break;
case 7:
echo “b equal to 7”;
break;
case 8:
echo “b equal to 8”;
break;
case 9:
echo “b equal to 9”;
break;
default:
echo “Doesn’t match the number”;
break;
}

?>

Question No. 4 Marks : 1

Write a program in Ada that prints Excellent to a gpa value>= 3.5, prints Good
to a gpa value in the range of 3-3.5,
prints Satisfactory to a gpa value in the range of 2-3.

Question No. 5 Marks : 1

A) How do Ada and COBOL differ by syntax and semantics in referencing a record
element? Give examples of each (5)

B) Define and explain “throws Clause” and the “finally Clause” with respect to
exception handling in Java. (5)
CS508- Modern Programming Languages
Midterm Fall2005
www.vujannat.ning.com
Q.1: Discuss the significance of readability as the language evaluation criterion.
Readability:
Q.2: Convert the following code in C in to equivalent LISP code using the most appropriate
constructs:
Q.3: Identify the mistake(s) in the following Ada code segment. After correcting it, convert it into
equivalent C and LISP code:
Q.4: We studied several reasons to study programming languages. With that context in mind
discuss:
(a) Increased capacity to express programming concepts
(b) Improved background for choosing appropriate languages and
show the output.
Q.5: For the following SNOBOL program, explain the meaning of each line
Q.6: Discuss the difference between enumeration types of C and Ada. Which is better and why?
www.vujannat.ning.com

CS508 Modern Programming Languages


Mid Term Examination – Spring 2006
Time Allowed: 90 Minutes

Please read the following instructions carefully before


attempting any of the questions:
1. Attempt all questions. Marks are written adjacent to each
question.
2. Do not ask any questions about the contents of this
examination from anyone.
a. If you think that there is something wrong with any of the
questions, attempt it to the best of your understanding.
b. If you believe that some essential piece of information is
missing, make an appropriate assumption and use it to solve
the problem.
c. Write all steps, missing steps may lead to deduction of
marks.

**WARNING: Please note that Virtual University takes serious note of


unfair means. Anyone found involved in cheating will get an `F` grade in
this course.

Question No. 1 Marks : 2

Ada pointers are called Access types.

 TRUE
 FALSE

Question No. 2 Marks : 10

Give the short answers of the following:


a) Comparison between functional and imperative languages?
Differentiate between the Dynamic Type binding and Static type binding?

Question No. 3 Marks : 15

Convert the following C code into equivalent LISP code using the most appropriate
constructs:

switch (VAR) {
case ‘M’ :
case ‘P’ :
case ‘L’ :
case ‘C’ :
case ‘S’ :
cout << “THIS IS A MPL CS COURSE”;
break;
case ‘F’ :
case ‘O’ :
case ‘L’ :
case ‘L’ :
case ‘O’ :
case ‘W’:
cout << “FOLLOW”;
break;
default:
cout << “ANY OTHER”;
}

Question No. 4 Marks : 2

Dynamic binding occurs at:

 Compile Time
 Design Time
 Link Time
 Run Time

Question No. 5 Marks : 15

Convert the following Ada code into equivalent C code.

case ch is
when ‘A’ | ‘E’ | ‘I’ | ‘O’ | ‘U’ =>
putline(“this is an uppercase vowel”);
when ‘J’ .. ‘N’ =>
putline(“between uppercase J and N”);
when others =>
putline(“something else”);
end case;

Question No. 6 Marks : 2

The dangling pointer problem is partially alleviated by Ada design.

 TRUE
 FALSE

Question No. 7 Marks : 2

Which statement is wrong about Static variables?

 They are bound to memory cells before the execution of program


 They use to direct access the memory.
 There is run time overhead of allocation and de-allocation of memory.
 Storage can’t be shared among variables

Question No. 8 Marks : 2

Prolog language falls under the domain of:

 Scientific Applications
 Business Applications
 Special Purpose Languages
 None of these

You might also like