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. runtime exception

  2. 6

  3. 7

  4. comiple error.

  5. 10

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

The variable i is declared inside the for loop header, so its scope is limited to the loop body. When System.out.println(i) executes after the loop, i is out of scope, causing a compilation error. Option A is wrong because there's no runtime - compilation fails. Options B, C, and E are incorrect because the code never runs.

Multiple choice technology programming languages
  1. Runtime exception

  2. 6

  3. 7

  4. Compile Error

  5. 11

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

The variable i is declared inside the for loop header (int i=0), limiting its scope to the loop body. The System.out.println(i) statement after the loop tries to access i outside its scope, causing a compilation error. Options A, B, C, and E are incorrect because the code never compiles or runs.

Multiple choice technology programming languages
  1. True

  2. False

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

Java 1.5 introduced autoboxing, which automatically converts primitive int to Integer when needed. The statement mylist.add(5) works because the int 5 is autoboxed to Integer. The code compiles and runs without error, so the statement that it gives compilation error is false.

Multiple choice technology web technology
  1. Load ( )

  2. Fill( )

  3. DataList

  4. DataBind

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

The DataAdapter's Fill() method is used to populate a DataSet or DataTable with data from a data source. The Fill method executes the query and retrieves the data into the dataset. Load is not a DataAdapter method, DataList is a control, and DataBind is for binding data to controls.

Multiple choice technology programming languages
  1. a(100, 200), b(100, 200)

  2. a(100, 200), b(700, 800)

  3. a(700, 800), b(100, 200)

  4. a(700, 800), b(700, 800)

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

In Java, objects are passed by reference. Method a modifies the actual object's fields, changing x to 100 and y to 200. Method b reassigns the local reference variable to a new Point object, but this doesn't affect the original object. So after method a: (100, 200), after method b: (700, 800) unchanged.

Multiple choice technology programming languages
  1. 33, 33

  2. 123, 33

  3. 33, 123

  4. 123, 123

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

In the first statement, 1+2=3 is evaluated first (arithmetic before string concatenation), then concatenated with "3" to produce "33". In the second statement, "1"+2 produces "12" (string concatenation), then "12"+3 produces "123". String concatenation starts when a string is encountered.

Multiple choice technology mainframe
  1. output on the terminal: result = 2 3 5

  2. output on the terminal: result = 3 2 1

  3. output on the terminal: result = var_3 var_4 var_5

  4. the program will terminate with an error

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

The REXX code has a syntax error in the IF clause: IF var_1 = var_2 uses a single equals sign, which in REXX is an assignment operator, not a comparison operator. The correct comparison would be IF var_1 == var_2. The syntax error causes the program to terminate, making option D correct.

Multiple choice technology mainframe
  1. Ia loop unconditionally and continues with the next clause after the loop

  2. IF var_1 = var_2 THEN var_1 = var_1 + a loop and EXEC unconditionally, but doesn't return to the caller of the EXEC.

  3. a loop and EXEC unconditionally, returns to the caller of the EXEC and provides a return code.

  4. a loop and EXEC unconditionally, returns to the caller of the EXEC, but doesn't provide a return code.

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

The EXIT clause in JCL terminates a loop immediately and transfers control back to the calling EXEC with a return code. This is different from a normal loop exit which would continue with the next statement after the loop. The return code allows the calling program to check if the EXEC completed successfully or encountered a condition that required early termination.

Multiple choice technology mainframe
  1. the external subroutine SUBROUT1 will be executed, bypassing any internal subroutines.

  2. the internal subroutine SUBROUT1 will be executed; external subroutines aren't called.

  3. the internal subroutines will be searched for SUBROUT1; only if there isn't an internal one, the external SUBROUT1 will be executed.

  4. an error will occur; subroutine names must never be coded between quotes.

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

In COBOL, when calling a subroutine using a literal string like CALL 'SUBROUT1', the compiler resolves this as a call to an external program or subroutine, bypassing any internal program structure.

Multiple choice technology mainframe
  1. One can not shield variables in a subroutine from the main EXEC, only from other subroutines.

  2. One can shield the variables by using the clause: CALL SUBROUT1 PROCEDURE

  3. One can shield the variables by defining the start clause of a subroutine:SUBROUT1: PROCEDURE

  4. One can shield the variables by defining the start clause of a subroutine: SUBROUT1: SHIELDED

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

Internal subroutines shield their variables from the main EXEC when defined with the PROCEDURE clause. This creates a local variable scope where variables defined inside the subroutine are not accessible to the calling EXEC. The correct syntax is SUBROUT1: PROCEDURE which defines the start of the subroutine with variable shielding.

Multiple choice technology mainframe
  1. This value must be numeric.

  2. This value can be alphanumeric.

  3. This value is stored in the system variable RC.

  4. This value is stored in the system variable RCODE.

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

When a RETURN clause is used in a subroutine, the value passed back can be alphanumeric (text or numeric). This value is returned to the calling EXEC but is not stored in RC or RCODE system variables as those are used for return codes from programs, not subroutine return values. The RETURN clause supports flexible data types.

Multiple choice technology web technology
  1. Thread.Interrupt()

  2. Thread.Abort()

  3. Both A) and B)

  4. None of the Above

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

Thread.Interrupt() causes a thread to throw ThreadInterruptedException when it enters a wait state, while Thread.Abort() raises ThreadAbortException to terminate the thread. Both methods can stop thread execution, though Abort() is deprecated in modern .NET due to potential data corruption.

Multiple choice technology programming languages
  1. Compilation error.

  2. Runtime error

  3. Compiles Fine

  4. Depends on the code where you use

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

This code has a type mismatch - List expects Object elements, but ArrayList can only contain Strings. In Java generics, you cannot assign a more specific generic type (ArrayList) to a more general reference (List) because it would allow type violations at compile time.