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
  1. A research institute

  2. A numerical computing environment

  3. A fifth generation programming language

  4. A virtual laboratory

  5. A science fiction

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

MATLAB (matrix laboratory) is a numerical computing environment and fourth-generation programming language.

Multiple choice
  1. //

  2. <!__ __>

  3. /* */

  4. #

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

PHP supports three comment styles: single-line comments using // and #, and multi-line comments using /* */. The syntax is not a valid PHP comment style - it resembles HTML comments but is incorrect for PHP code.

Multiple choice
  1. <?php?>

  2. <script language=php> </script>

  3. <? ?>

  4. <?% %>

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

PHP supports multiple tag styles: standard , short tags ?>, and script tags . The ASP-style tags <% %> were supported in older PHP versions with asp_tags enabled but were removed in PHP 7.0, making them the most incorrect option among modern PHP installations.

Multiple choice
  1. client side

  2. server side

  3. client/server side

  4. none of above

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

PHP is a server-side scripting language that executes on the web server before sending HTML to the client's browser. Unlike JavaScript (client-side), PHP code runs entirely on the server and the browser never sees the PHP source.

Multiple choice
  1. array([key=>] value,.......)

  2. array)key=>value,.........)

  3. Both (1) and (2)

  4. None of these

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

PHP arrays are created using array() with optional key-value pairs: array('key' => 'value', 'key2' => 'value2'). The => operator associates keys with values. Modern PHP also supports the shorter [] syntax.

Multiple choice
  1. func_get_arg

  2. func_get_args

  3. func_num_args

  4. none of these

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

func_get_args() returns an array containing all arguments passed to the current function. This is useful for variable-length argument lists. Related functions: func_num_args() returns count, func_get_arg(n) returns single argument at position n.

Multiple choice
  1. func_get_arg

  2. func_get_args

  3. func_num_args

  4. none of these

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

func_num_args() returns the total number of arguments passed to a user-defined function. Unlike func_get_arg() (which gets a specific argument by index) or func_get_args() (which returns the entire array of arguments), this function only returns the count.

Multiple choice
  1. isset

  2. set

  3. exist

  4. none of these

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

isset() is a PHP language construct that determines whether a variable is set and is not NULL. It returns true if the variable exists and has a value other than NULL. This is commonly used to check if form fields or array keys have been initialized before using them.

Multiple choice
  1. Assign

  2. Include

  3. List

  4. All of the above

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

The list() construct in PHP assigns array elements to variables in a single operation, treating the array values as if they were being assigned to individual variables. It's commonly used with arrays that have numeric indices. For example: list($a, $b) = array(1, 2) assigns 1 to $a and 2 to $b.

Multiple choice
  1. array_funct

  2. array_walk

  3. array_apply

  4. in_array

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

array_walk() applies a user-defined callback function to each element of an array. This is useful for performing operations on every array element, such as formatting, validation, or transformation. The callback function receives the element's value and optionally its key and index.

Multiple choice
  1. require()

  2. require_once()

  3. both (1) and (2)

  4. include

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

Both require() and require_once() cause fatal errors and terminate the script if the included file cannot be found or cannot be opened. This is different from include() and include_once(), which only generate warnings and allow the script to continue. The '_once' variants ensure the file is included only once even if called multiple times.

Multiple choice
  1. call

  2. include

  3. access

  4. both (1) and (2)

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

The include() function (and its variants include_once(), require(), require_once()) allows you to insert the contents of one PHP file into another before the server executes it. This enables code reuse and modular design by separating PHP code into multiple files and including them as needed.