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. x: 6 y: 16

  2. x: 10 y: 26

  3. x: 10 y: 15

  4. x: 6 y: 15

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

The postfix increment operator x++ evaluates to the current value of x (which is 5) before incrementing it to 6. Thus, y += 5 sets y to 15, and x is updated to 6, matching the correct output.

Multiple choice technology web technology
  1. Coldfusion

  2. PHP

  3. Python

  4. ASP

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

PHP uses as its standard opening and closing tags, with the short form ?> also available when short_open_tag is enabled in configuration. This syntax embeds PHP code within HTML files. Other languages like Coldfusion use , Python is not typically embedded in HTML this way, and ASP uses <% %> tags.

Multiple choice technology performance
  1. for (var i = 0; i < arr.length; i++) { // some code here }

  2. for (var i = 0, len = arr.length; i < len; i++) { // some code here }

  3. for (var i = arr.length; i--; ) { // some code here }

  4. for ( i = 0; i < arr.length; i++) { // some code here }

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

A decrementing loop checking against zero (i--) is historically the fastest in JavaScript because the termination check does not require querying a property (arr.length) or comparing variables on every iteration. Other options perform redundant length lookups or property evaluations inside the loop condition.

Multiple choice technology web technology
  1. JavaScript

  2. Java

  3. Perl

  4. Rexx

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

JavaScript was originally named Mocha when it was created by Brendan Eich at Netscape in 1995. It was briefly renamed LiveScript before being officially launched as JavaScript. The name change was partly a marketing move to capitalize on Java's popularity, though the languages are unrelated.

Multiple choice technology web technology
  1. It is immutable

  2. Simplifies strng manipulations

  3. Simplifies concurrent multithreaded programming

  4. None of the above

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

System.String is immutable, which makes it inherently thread-safe. Multiple threads can access and read the same String object simultaneously without locks or synchronization, unlike StringBuilder which requires explicit coordination in multithreaded environments.

Multiple choice technology mainframe
  1. COBOL

  2. CICS

  3. REXX

  4. Easytrieve

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

COBOL, REXX, and Easytrieve are all programming languages used on mainframe systems. CICS (Customer Information Control System) is a transaction processing system/middleware, not a programming language. It's an environment that runs programs written in languages like COBOL.

Multiple choice technology programming languages
  1. Convert.ToString() handle null values but ToString() don't

  2. ToString() output as per format supplied

  3. Convert.ToString() only handle null values

  4. ToString() handle null values but Convert.ToString() don't

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

The critical difference is null handling: calling ToString() on a null reference throws NullReferenceException, while Convert.ToString(null) returns null without throwing. Convert.ToString() also handles various type conversions via IConvertible, while ToString() is the instance method for string representation.

Multiple choice technology programming languages
  1. StringBuilder is more efficient when there is a large amount of string manipulation

  2. Strings are immutable, so each time a string is changed, a new instance in memory is created.

  3. StringBuilder is mutable; when you modify an instance of the StringBuilder class, you modify the actual string, not a copy

  4. Strings are mutable in .Net

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

System.String is immutable - every operation creates a new string object in memory. StringBuilder is mutable - modifications happen in-place on the same instance. Therefore, the statement "Strings are mutable in .Net" is false, making D the correct choice for the incorrect statement. Options A, B, and C all describe actual differences correctly.

Multiple choice technology programming languages
  1. HashTable

  2. ArrayList

  3. SortedList

  4. All of above

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

HashTable (and its generic version Dictionary) is designed specifically for key-value access where each key must be unique. ArrayList and SortedList store elements without requiring unique keys - ArrayList is a dynamic array and SortedList maintains sorted order but allows duplicates.

Multiple choice technology web technology
  1. Declare as null

  2. Declare as Null and Call the dispose method

  3. Call GC.SupressFinalize method for the object

  4. None of the above

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

For objects that are no longer needed and implement IDisposable, you should set the reference to null AND call the Dispose() method to release unmanaged resources promptly. Setting to null helps the garbage collector by removing the reference, while Dispose releases resources like file handles or database connections immediately rather than waiting for finalization.

Multiple choice technology web technology
  1. if(stringValue == null)

  2. if(string.IsNullOrEmpty(stringValue))

  3. if(stringValue == DbNull.value)

  4. None of the above

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

When checking database values stored in an ADO.NET DataSet, missing database values are represented by DBNull.Value, not C# null. Thus, comparing the value to DBNull.Value is correct. Note that the option text contains a typo 'DbNull.value' instead of 'DBNull.Value', but it represents the correct concept.

Multiple choice technology web technology
  1. It does not cover all the functions as covered by System.Net.Mail

  2. It is obsolete as compared to System.Net.Mail

  3. It is not secure way of sending mails.

  4. None of the above

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

System.Web.Mail is marked as obsolete and deprecated by Microsoft. It was replaced by System.Net.Mail which provides better functionality, security, and maintainability. Using obsolete classes is discouraged as they may be removed in future versions and often lack modern features. System.Net.Mail became the standard starting with .NET Framework 2.0.

Multiple choice technology web technology
  1. printf("Hello World")

  2. echo "Hello World";

  3. "Hello World";

  4. Document.write("Hello World");

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

echo is the correct way to output text in PHP. While printf also works for formatted output, echo is the standard method for simple string output and is the most commonly used. Option C is just a string literal without an output command, and option D uses JavaScript syntax.