VU LIVE
📢 Browse Moaaz & Arslan Papers — CS, MTH, ENG, MGT and more — Free study resources
All Pages Linked

CS508 — Modern Programming Languages: Midterm & Finalterm Solved MCQs and Subjective

Virtual Ustaad Verified VU Resource Report a wrong answer
CS508 Modern Programming Languages — VU solved MCQs

CS508 Modern Programming Languages covers language evaluation criteria, history, data types, control structures, subprograms and the languages FORTRAN, COBOL, LISP, SNOBOL, Ada, C/C++, Java, C#, PHP, JavaScript and Prolog, including readability, writability, reliability, orthogonality and aliasing. This solved post gives you 30 verified items for Virtual University of Pakistan, 10 Midterm MCQs from Lectures 1-22, 10 Finalterm MCQs from Lectures 23-45, and 5 Midterm plus 5 Finalterm subjective questions, each with its correct answer and handout reference. Practice every question instantly in the quiz for this course. Take the CS508 quiz

1. Midterm Solved MCQs

Q1. Unlike C/C++, Ada can have __________ within functions/procedures.
A) Objects
B) Functions/procedures
C) Events
D) Parameters
Correct answer: B — Functions/procedures
Reference: VU handout, Lecture 10 — Ada; nested subprograms.
Status: Verified

Q2. Function must have at least ________ return statement.
A) Three
B) Two
C) One
D) Four
Correct answer: C — One
Reference: VU handout, Lecture 11 — Subprograms; functions.
Status: Verified

Q3. Imperative programming languages are the direct result of ________.
A) Charles Babbage engine
B) Logic or list program languages
C) Von Neumann architecture
D) Language application domain
Correct answer: C — Von Neumann architecture
Reference: VU handout, Lecture 2 — Programming language history; von Neumann architecture.
Status: Verified

Q4. To write a user defined function in LISP we use __________.
A) Setq
B) Defun
C) Def func
D) func
Correct answer: B — Defun
Reference: VU handout, Lecture 13 — LISP.
Status: Verified

Q5. Function in LISP is in _________ notation.
A) postfix
B) infix
C) prefix
D) None of the given
Correct answer: C — prefix
Reference: VU handout, Lecture 13 — LISP.
Status: Verified

Q6. ______________ is The First High Level Language.
A) FORTRAN
B) Ada
C) Plankalkül
D) LISP
Correct answer: A — FORTRAN
Reference: VU handout, Lecture 3 — History of programming languages.
Status: Verified

Q7. COBOL is mainly designed for ___________.
A) Scientific experiments
B) Business application
C) AI applications
D) Publishing and writing algorithm
Correct answer: B — Business application
Reference: VU handout, Lecture 3 — COBOL.
Status: Verified

Q8. First electronic computer was __________.
A) ENIAC
B) Babbage Analytical Engine
C) Intel 386
D) IBM x86
Correct answer: A — ENIAC
Reference: VU handout, Lecture 2 — History of computing.
Status: Verified

Q9. PROLOG represent paradigm.
A) Declarative
B) Formal
C) Functional
D) Algorithmic
Correct answer: A — Declarative
Reference: VU handout, Lecture 15 — Prolog.
Status: Verified

Q10. SNOBOL was designed for _________ purpose.
A) String manipulation
B) AI
C) Business
D) Scientific
Correct answer: A — String manipulation
Reference: VU handout, Lecture 6 — SNOBOL.
Status: Verified

2. Finalterm Solved MCQs

Q1. In C# the value type and reference type variable are interconvertible through ________ concept.
A) Tagged type
B) boxing
C) Interfaces
D) None of the given
Correct answer: B — boxing
Reference: VU handout, Lecture 24 — C#; boxing and unboxing.
Status: Verified

Q2. With programming in ____________ we state what and not how.
A) Prolog
B) Algol
C) C#
D) Fortran
Correct answer: A — Prolog
Reference: VU handout, Lecture 15 — Prolog; declarative paradigm.
Status: Verified

Q3. When the type is fixed before run time then this is called as ___________.
A) Load time binding
B) Static binding
C) Dynamic binding
D) None of the given
Correct answer: B — Static binding
Reference: VU handout, Lecture 17 — Type binding.
Status: Verified

Q4. A programming language is ___________ typed if type errors are _____________ detected.
A) Weakly, Always
B) Always, weakly
C) Strongly, often
D) Strongly, always
Correct answer: D — Strongly, always
Reference: VU handout, Lecture 17 — Strong typing.
Status: Verified

Q5. ___________ programming language is known as "Write only" language.
A) FORTRAN
B) BASIC
C) APL
Correct answer: C — APL
Reference: VU handout, Lecture 3 — APL.
Status: Verified

Q6. All primitive types in ___________ have fixed size.
A) FORTRAN
B) C++
C) JAVA
D) C#
Correct answer: C — JAVA
Reference: VU handout, Lecture 18 — Java data types.
Status: Verified

Q7. Which chaining type is used by Prolog?
A) Backward
B) Forward
C) Up
D) Horizontal
Correct answer: A — Backward
Reference: VU handout, Lecture 16 — Prolog; inference.
Status: Verified

Q8. It is always better to find out the mistakes in the code at ________.
A) Runtime
B) Compile time
C) Link time
D) None of given option
Correct answer: B — Compile time
Reference: VU handout, Lecture 1 — Language evaluation; reliability.
Status: Verified

Q9. We can have nested procedures in _________ language.
A) C++
B) Ada
C) C
D) PROLOG
Correct answer: B — Ada
Reference: VU handout, Lecture 10 — Ada; nested subprograms.
Status: Verified

Q10. C# code when compiled is converted into ________ code.
A) MSIL
B) MISL
Correct answer: A — MSIL
Reference: VU handout, Lecture 24 — C#; .NET.
Status: Verified

3. Midterm Subjective

Q1. What are the two main elements of LISP? Differentiate between an atom and a list.
Answer: The two main elements of LISP are atoms and lists. An atom is a single indivisible element — a number, a symbol or a string (e.g. 5, x, "hello"). A list is a sequence of atoms and/or other lists enclosed in parentheses (e.g. (a b c), (3 4 5)). The first element of a list is conventionally the function (or operator) and the rest are its arguments, so (+ 2 3) is the list whose evaluation gives 5. Everything in a LISP program — code and data — is built from atoms and lists.
Reference: VU handout, Lecture 13 — LISP; atoms and lists.
Status: Verified

Q2. Show syntactically how a function is defined in LISP. Give an example.
Answer: A function is defined with defun: (defun function-name (parameter-list) body). Example: (defun square (x) (* x x)) defines a function square that returns the square of its argument; calling (square 5) gives 25. The body is a list whose first element is the function to apply (*) and the rest are its arguments — LISP's prefix notation.
Reference: VU handout, Lecture 13 — LISP; defun.
Status: Verified

Q3. Differentiate between the Ada record type and the C/C++ struct. Give a struct example.
Answer: Both group heterogeneous data under one name, but they differ: an Ada record is a strongly typed, named composite type whose fields are accessed with the dot operator, e.g. type Employee is record Name: String(1..20); Salary: Float; end record; — Ada checks the field types strictly and records can have discriminants and variants. A C/C++ struct is similar in shape — struct Employee { char name[20]; float salary; }; — but C/C++ are weakly typed by comparison: struct fields can be accessed through pointers, type conversions are looser, and a struct in C++ can also contain member functions. In short: same idea (a record of named fields), different type discipline — Ada's record is part of a strongly typed language, the C/C++ struct is a looser aggregate.
Reference: VU handout, Lecture 10 — Ada records; C/C++ struct.
Status: Verified

Q4. What types of loop are there in Ada? Explain each briefly.
Answer: Ada has three loop forms: (1) the loop … end loop; — an unconditional loop that runs until an exit statement is executed; (2) the while loop — while condition loop … end loop; — repeats while the condition is true, tested before each iteration; (3) the for loop — for I in 1..10 loop … end loop; — iterates over a discrete range (or a reverse range), with the loop variable declared implicitly and read-only inside the loop. Ada has no C-style do-while loop; the plain loop with an exit when is used instead.
Reference: VU handout, Lecture 10 — Ada control structures.
Status: Verified

Q5. What is orthogonality in programming languages? Why does it matter?
Answer: Orthogonality means that the features of a language combine freely and independently, with few exceptions or restrictions: any combination of primitives that makes sense should be allowed. Example: in a highly orthogonal language, a pointer can point to any type, and an array can hold any type. It matters because it increases readability and writability — there are fewer special cases to remember, and the programmer can combine features in predictable ways. The opposite is a language full of arbitrary restrictions (e.g. "you can have arrays of integers but not arrays of records"), which is harder to learn and use. (Sebesta's evaluation criteria: readability, writability, reliability, cost.)
Reference: VU handout, Lecture 1 — Language evaluation criteria; orthogonality.
Status: Verified

4. Finalterm Subjective

Q1. Describe the programming steps in Prolog (5 marks).
Answer: Programming in Prolog means: (1) declare facts — statements known to be true, e.g. parent(tom, bob).; (2) declare rules — implications that define new relations, e.g. grandparent(X, Z) :- parent(X, Y), parent(Y, Z).; (3) pose a query (goal) — e.g. ?- grandparent(tom, Z).; (4) the system uses backward chaining (resolution) to prove the goal: it matches the goal against facts and rule heads, unifies variables, and backtracks when a choice fails; (5) it reports the variable bindings that make the goal true (or false/no if none exist). Unlike imperative programming, the programmer states what is true, not how to compute it.
Reference: VU handout, Lecture 16 — Prolog programming.
Status: Verified

Q2. How are arrays different from records? Justify your answer.
Answer: An array is a homogeneous aggregate: all its elements have the same type and are accessed by an index (a position), e.g. int scores[10] — the elements are scores[0] … scores[9]. A record (struct) is a heterogeneous aggregate: its fields can have different types and are accessed by name, e.g. a record with fields name (string) and salary (float). So the differences are: (1) element types — same in an array, mixed in a record; (2) access — by numeric index vs by field name; (3) use — arrays model collections of similar items, records model one entity with several different attributes. (In the handout's words: a record is "a logical grouping of heterogeneous elements".)
Reference: VU handout, Lecture 6 — Data types; arrays and records.
Status: Verified

Q3. Write three features of C# which are not available in Java.
Answer: (1) Properties — C# has get/set accessors built into the language, so a field-like member can run code on access; Java needs explicit getter/setter methods. (2) Events and delegates — C# has first-class delegates and the event keyword for type-safe event handling; Java uses listener interfaces. (3) Operator overloading — C# allows user-defined types to overload operators (+, ==, …); Java does not allow operator overloading. (Other valid answers: indexers, unsafe code and pointers, ref/out parameters, structs/value types, and the foreach over any enumerable — Java's equivalents differ or are absent.)
Reference: VU handout, Lecture 24 — C# vs Java.
Status: Verified

Q4. Write code in C# to implement an enumeration of 12 months named YEAR.
Answer: enum YEAR
{
January, February, March, April, May, June,
July, August, September, October, November, December
}
By default the members take the values 0–11; explicit values can be given, e.g. January = 1, February = 2, …. Usage: YEAR m = YEAR.March; — an enumeration is a value type whose members are named constants of an underlying integral type (int by default).
Reference: VU handout, Lecture 24 — C# enumerations.
Status: Verified

Q5. Write code in Java to convert a double data type into an int. How is information lost in this type conversion?
Answer: double d = 9.75;
int i = (int) d; // i becomes 9
The conversion needs an explicit cast because it is a narrowing conversion (double is 64-bit, int is 32-bit). Information is lost in two ways: (1) the fractional part is truncated — 9.75 becomes 9, not rounded to 10; (2) if the double's value is outside the int range (about ±2.1 × 10⁹), the result is undefined/wrapped and the magnitude is lost. Java performs widening conversions (int → double) automatically, but narrowing conversions must be written explicitly with a cast.
Reference: VU handout, Lecture 18 — Java type conversions.
Status: Verified

Frequently asked questions

Is the Midterm from Lectures 1-22?
Yes — Midterm covers Lectures 1-22 and Finalterm covers Lectures 23-45.

Does the quiz work from this post?
Yes — use the 'Take the CS508 quiz' link above; the quiz is already live for this course.

Are the answers verified?
Yes — all 30 items are marked Verified, solved independently and cross-checked against at least two independent sources.

More Solved Papers

See the Solved MCQs page and the midterm and finalterm mega hubs for solved papers for every subject.

Comments

Advertisement
Advertisement

Tool