Computer Knowledge

Programming Languages and Compilers

2,284 Questions

Programming languages and compilers involve the rules, syntax, and semantics used to write and execute software programs. Key areas include scripting languages, object oriented concepts, and parsing algorithms like top down parsers. Practice these computer science questions to build proficiency for technical and computer knowledge exams.

Object oriented languagesScripting languagesCompilers and parsersProgramming syntax

Programming Languages and Compilers Questions

Multiple choice technology programming languages
  1. True

  2. False

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Generics were introduced in Java 5 (J2SE 5.0, released in 2004), not in Java 1.4. Java 1.4 was released in 2002 and did not include generic type support. The introduction of generics allowed developers to write type-safe collections and eliminate the need for explicit casting when retrieving objects from collections.

Multiple choice technology databases
  1. NEW_LINE

  2. PUT

  3. PUT_LINE

  4. PUTF

  5. None of the above

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

PUT_LINE in UTL_FILE package writes text to a file and automatically appends a line terminator (newline character) after each call. PUT writes without any terminator, while PUTF is for formatted output without automatic line termination. NEW_LINE is not a valid UTL_FILE procedure.

Multiple choice technology
  1. NSLog()

  2. Printf()

  3. System.out.println()

  4. Scanf()

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

NSLog() is the standard function for logging objects to the console in Objective-C. It works with Objective-C objects and format strings, similar to printf() but specifically designed for Cocoa/Cocoa Touch frameworks. printf() is a C function, System.out.println() is Java, and scanf() is for input.

Multiple choice technology
  1. -(void)setPrice:(float)newPrice;

  2. -(void)setPrice:float newPrice;

  3. -void setPrice:(float)newPrice;

  4. -void setPrice:float newPrice;

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Objective-C method declarations require the return type in parentheses after the minus sign. The correct syntax is -(returnType)methodName:(parameterType)parameterName;

Multiple choice technology
  1. C#

  2. Python

  3. Perl

  4. Jython

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Python was created by Guido van Rossum and first released in 1991. It is known as a general-purpose, very-high level programming language. C# was created by Microsoft (Anders Hejlsberg), Perl by Larry Wall, and Jython is a Python implementation for JVM (not by Guido). The name 'Von Russom' is a typo for 'van Rossum'.

Multiple choice java
  1. The class is fully encapsulated

  2. The code demonstrates polymorphism

  3. The ownerName variable breaks encapsulation

  4. The cardID and limit variables break polymorphism

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Proper encapsulation requires all fields to be private with controlled access through methods. The ownerName field is public, breaking encapsulation. CardID and limit are correctly private. Option A is wrong (not fully encapsulated). Option B is wrong (no polymorphism shown). Option D is wrong (private fields don't break polymorphism).

Multiple choice technology programming languages
  1. The class is fully encapsulated

  2. The code demonstrates polymorphism

  3. The ownerName variable breaks encapsulation

  4. The cardID and limit variables break polymorphism

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Proper encapsulation requires all fields to be private with access controlled through getters and setters. The ownerName field is declared public, allowing direct external access and modification - this breaks encapsulation regardless of the setter method's presence.

Multiple choice technology mainframe
  1. Subscripting enables us to write a more compact code in the procedure division.

  2. Subscripting enables us to refer to any element of a table by the same data name with the facility of identifying the particular element through the values of subscript

  3. Subscripting reduces the number of entries to be included in the data division.

  4. Subscripting enables us to use loops in the procedure division.

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

The question asks which statement is INCORRECT. Subscripting allows referring to table elements by index, reduces data division entries, and enables compact code. However, subscripting itself is a table access mechanism - it doesn't inherently enable loops (PERFORM with VARYING enables loops). So claiming subscripting enables loops is incorrect.

Multiple choice technology web technology
  1. Faster

  2. Slower

  3. The execution speed is similar

  4. All of above

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

To solve this question, the user needs to know basic concepts of programming languages and how they are executed.

The answer is:

B. Slower

Scripts are interpreted line by line during runtime, whereas compiled programs are translated into machine language (binary code) before runtime. This means that compiled programs are faster than scripts because they do not require interpretation during runtime. On the other hand, scripts are easier to write, modify, and debug because they do not need to be compiled before execution.

Multiple choice technology web technology
  1. Open source general purpose

  2. Proprietary general purpose

  3. Open source special purpose

  4. Proprietary special purpose

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

PHP is an open-source, general-purpose scripting language that is especially suited for web development and can be embedded into HTML. The 'open source' designation means the source code is freely available for anyone to use, modify, and distribute. 'General purpose' indicates it's not limited to web-only tasks - PHP can be used for command-line scripting, GUI applications, and more. Option B incorrectly calls it proprietary (it's not owned by a single company), while options C and D incorrectly suggest it's limited to special purposes.