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 general knowledge science & technology
  1. Common Business Objective Language

  2. Common Business Oriented Language

  3. Common Business Oriental Language

  4. None Of the above

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

COBOL stands for Common Business Oriented Language. It was designed for business applications. 'Oriental' is incorrect, and 'Objective' doesn't fit the language's purpose.

Multiple choice general knowledge science & technology
  1. SmallTalk

  2. C++

  3. Ruby

  4. Jade

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

SmallTalk was the first object-oriented programming language with an integrated graphical user interface featuring overlapping windows, integrated documents, and cut & paste editing. C++ and Ruby came later, and Jade doesn't match these pioneering features.

Multiple choice general knowledge science & technology
  1. BeansScript

  2. SunScript

  3. LiveScript

  4. ClassScript

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

JavaScript was originally developed by Netscape under the name LiveScript in 1995. It was renamed to JavaScript shortly before release as a marketing move to capitalize on the popularity of Java. The name change caused ongoing confusion between the two unrelated languages.

Multiple choice general knowledge science & technology
  1. Short Code

  2. PASCAL

  3. C++

  4. JAVA

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

Short Code, developed in 1949-1950, was the first high-level programming language actually implemented on an electronic computer (the UNIVAC). It required manual translation to machine code, making it more of a pseudocode system, but represented the first attempt to abstract away from raw machine instructions. Pascal (1970), C++ (1983), and Java (1995) came much later.

Multiple choice general knowledge science & technology
  1. Translator

  2. Locator

  3. Assembler

  4. Compiler

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

A compiler is a program that translates high-level programming languages (like C++, Java) into low-level machine code that the computer can execute. While assemblers and translators also handle code conversion, the compiler specifically handles high-level to low-level translation for languages with complex abstractions. A locator is unrelated to language translation.

Multiple choice general knowledge science & technology
  1. Procedural

  2. Non-Procedural

  3. Both of the Above

  4. Non of the Above

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

Fourth-generation languages (4GL) are non-procedural, meaning you specify what result you want rather than how to achieve it step-by-step. Examples include SQL and query languages where you declare the desired data without detailing the retrieval algorithm. This contrasts with procedural languages (3GL) like C or Java where you explicitly write execution steps.

Multiple choice general knowledge science & technology
  1. The program has a syntax error

  2. The program has a runtime error

  3. The program runs fine, but displays nothing

  4. The program runs fine and displays It is even!

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

The program prints 'It is even!' because the if condition uses assignment (=) instead of equality comparison (==). The statement 'even = true' assigns true to the variable even and returns true as the expression result, so the if block executes. This is a common mistake - using assignment instead of comparison. There is no syntax or runtime error, and output is produced.

Multiple choice general knowledge science & technology
  1. The program cannot compile because the compiler cannot determine which max method should be invoked

  2. The program cannot compile because you cannot have the print statement in a non-void method

  3. The program runs and prints "max(int, double) is invoked" followed by 2

  4. The program runs and prints "max(double, int) is invoked" followed by 2

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

When max(1, 2) is called with two int arguments, Java's compiler cannot determine whether to invoke max(int, double) or max(double, int) since both require an implicit type conversion (int to double). This ambiguity causes a compilation error.

Multiple choice general knowledge science & technology
  1. The program runs and prints 2 once

  2. The program runs and prints 2 twice

  3. The program has a syntax error because the second m method is defined, but not invoked in the main method

  4. The program has a syntax error because the two methods m have the same signature

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

Methods are distinguished by their signature - the method name AND parameter list (types and order). Both m() methods have the same signature (m(int)) - only the return type differs, which is not sufficient for overloading. This causes a compilation error.

Multiple choice general knowledge science & technology
  1. Program compiles correctly and prints "A" and "C" when executed

  2. Program compiles correctly and prints "A" when executed

  3. Program compiles correctly and prints "A","B" and "C" when executed

  4. Program compiles correctly and prints "A" and "B" when executed

  5. compile-time error

  6. run-time error

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

When System.exit(0) is called, the JVM terminates immediately without executing the finally block. The program prints A (before try), then B (inside try), then exits. The catch block is not executed because no exception is thrown, and finally is not reached because System.exit() terminates the program.

Multiple choice general knowledge science & technology
  1. float f = 1.3;

  2. byte b = 257;

  3. int i = 10;

  4. boolean b = null;

  5. char c = "a";

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

Only 'int i = 10' compiles without error. 'float f = 1.3' fails because 1.3 is a double literal requiring casting or 'f' suffix. 'byte b = 257' fails because 257 exceeds byte's range (-128 to 127). 'boolean b = null' fails because booleans can't be null. 'char c = "a"' fails because "a" is a String, not a char.

Multiple choice general knowledge science & technology
  1. High level Language

  2. Machine Language

  3. Micro Processor Language

  4. None of the Above

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

Java is a high-level programming language that abstracts away low-level machine details. It runs on a virtual machine (JVM) and uses automatic memory management. Machine language and microprocessor language are low-level, closer to hardware.

Multiple choice general knowledge science & technology
  1. High level Language

  2. Machine Language

  3. Micro Processor Language

  4. None of the Above

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

Java is a high-level programming language that abstracts away low-level machine details. It runs on a virtual machine (JVM) and uses automatic memory management. Machine language and microprocessor language are low-level, closer to hardware.