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 softskills creativity
  1. >5=-15

  2. <5=-15

  3. <5=15

  4. >5=15

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

When mixing signed and unsigned integers, C promotes the signed value to unsigned. -20 becomes a very large positive number (2^32-20 for 32-bit int). i+j (5 + large unsigned) exceeds 5, so the if condition is true. The printf uses %d to format j+i, which is -15 when viewed as signed. Option A is correct: >5=-15.

Multiple choice softskills creativity
  1. 123

  2. 6123

  3. 1236

  4. 3216

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

Function argument evaluation order in C is unspecified (typically right-to-left). The call sum(a(),b(),c()) evaluates c() first (prints 3), then b() (prints 2), then a() (prints 1). sum() adds 1+2+3=6, which printf prints. Output: 3216. The return values are used in the sum, not the print order.

Multiple choice softskills creativity
  1. Run-time Error

  2. True

  3. Compilation Error

  4. False

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

The code uses assignment (=) instead of equality (). In 'if(var = true)', the assignment happens first (var becomes true), then the condition evaluates the assigned value. Since true is truthy, the if-block executes, printing 'TRUE'. This is a common bug - the programmer likely meant to compare () but accidentally assigned. There's no compilation or runtime error - Java allows boolean assignment in conditions.

Multiple choice softskills creativity
  1. Interpreter

  2. Operating system

  3. Compiler

  4. Assembler

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

An operating system is system software that manages hardware and software resources. Interpreters, compilers, and assemblers are all language translators used to convert source code into machine code.

Multiple choice technology programming languages
  1. True

  2. False

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

Java is strongly typed because every variable must be declared with a type, and the compiler performs strict type checking to ensure that values assigned to variables are compatible with their declared types, preventing many runtime errors.

Multiple choice technology programming languages
  1. ProcessRequest and IsReusable

  2. ProcessResponse and IsReusable

  3. GenerateRequest and ProcessResponse

  4. GenerateResponse and ProcessRequest

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

The IHttpHandler interface in ASP.NET defines exactly two methods: ProcessRequest (which handles the HTTP request) and IsReusable (which indicates whether the handler can be pooled for reuse). Other options mention non-existent methods like ProcessResponse or GenerateRequest.

Multiple choice technology programming languages
  1. for (int i = 0; i < 80; i++) { stream1.WriteByte(byteArray[i]); bytesTransferred = i; if (!stream1.CanWrite) { break; }}

  2. bytesTransferred = stream1.Read(byteArray, 0, 80);

  3. while (bytesTransferred < 80) { stream1.Seek(1, SeekOrigin.Current); byteArray[bytesTransferred++] = Convert.ToByte(stream1.ReadByte());}

  4. stream1.Write(byteArray, 0, 80);bytesTransferred = byteArray.Length;

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

The Stream.Read(byte[], offset, count) method reads bytes from the stream into the array and returns the number of bytes actually read. Option B correctly uses this pattern. Option D writes TO the stream instead of reading from it. Options A and C use inefficient manual byte-by-byte loops.

Multiple choice technology programming languages
  1. myprog

  2. good

  3. morning

  4. Exception raised: "java.lang.ArrayIndexOutOfBoundsException: 2"

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

When you run java myprog good morning, the argv array has only 2 elements: argv[0]="good" and argv[1]="morning". Accessing argv[2] causes ArrayIndexOutOfBoundsException because index 2 doesn't exist.

Multiple choice technology programming languages
  1. one

  2. one, default

  3. one, two, default

  4. default

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

When i=1, case 1 matches and prints "one". Since there's no break statement, execution "falls through" to case 2 (prints "two") and then to default (prints "default"). Fall-through is a deliberate (and sometimes useful) feature in Java switch statements.

Multiple choice technology programming languages
  1. Using Only Get..EndGet with in property definition

  2. Using Only Set..EndSet with in property definition

  3. Using both Get and Set

  4. None of these

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

To create a read-only property in VB.NET, you use the ReadOnly modifier and define only the Get block within the property block, omitting the Set block.