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
-
a. LINE will hold the first record.
-
b. Error
-
c. LINE will hold the last record.
-
d. LINE is empty.
C
Correct answer
Explanation
In the LOOP AT ITAB INTO LINE construct, the work area LINE receives each row of the internal table during each iteration. After the loop completes, LINE contains the last record that was processed. This is standard ABAP behavior - the work area holds whatever value was last assigned to it. Option A is incorrect because LINE only temporarily holds one record at a time during iteration. Option B is incorrect because no error occurs. Option D is incorrect because LINE contains the last processed record, not nothing.
-
Open source general purpose
-
Proprietary general purpose
-
Open source special purpose
-
Proprietary special purpose
A
Correct answer
Explanation
PHP is fundamentally designed as an open-source, general-purpose scripting language. The 'open source' means its source code is freely available for anyone to use and modify. 'General purpose' indicates it can handle various types of programming tasks beyond web development, though it is especially well-suited for web applications. Options B and D are incorrect because PHP is not proprietary. Option C is incorrect because PHP is not limited to special purposes.
-
PHP can be used to develop web applications
-
PHP makes a website dynamic.
-
PHP applications can not be compiled.
-
PHP can not be embedded into html.
D
Correct answer
Explanation
This question asks which statement is NOT true (i.e., which is false). Option D claims 'PHP can not be embedded into html,' which is a false statement because PHP CAN indeed be embedded into HTML using PHP tags. Options A, B, and C are all true statements: PHP can develop web apps, PHP makes websites dynamic by generating content server-side, and PHP scripts are interpreted rather than compiled (though modern PHP can be compiled via various tools, the statement uses 'can not' which is technically accurate for traditional usage).
-
<? ?>
-
<script language=”php”> </script>
-
<% %>
-
<?php ?>
D
Correct answer
Explanation
The tag is the most portable PHP delimiter because it is XML-compliant and works in XHTML documents. Short tags like ?> depend on php.ini configuration and may not work in all environments. The tag format is verbose and rarely used. ASP-style tags <% %> are deprecated and removed in PHP 8. Using <?php ensures your code works across different server configurations and XML-based document types.
B
Correct answer
Explanation
PHP has several predefined superglobal variables: $_GET, $_POST, $_REQUEST, $_SERVER, $_SESSION, etc. These are auto-populated by PHP. The variable '$ask' is NOT a predefined PHP variable - it would need to be created by the developer. Options A, C, and D all refer to common PHP superglobals (though they should be written as $_GET, $_POST, $_REQUEST with underscores and in uppercase). The question tests knowledge of built-in versus custom variables.
-
It can never be changed or undefined
-
It can never be changed but can be undefined
-
It can be changed but can not be undefined
-
It can be changed and can be undefined
A
Correct answer
Explanation
Once a constant is defined in PHP using define(), it cannot be changed or undefined during script execution. This is the fundamental purpose of constants - to provide immutable values that remain consistent throughout the program. Option B is wrong because constants cannot be undefined either. Options C and D are incorrect because constants cannot be changed at all after definition. Constants are global in scope and their value is fixed for the entire script runtime.
-
Declarations
-
Scriptlets
-
Expressions
-
Include
A,B,C
Correct answer
Explanation
JSP has three main scripting elements: Declarations (<%! %>) for declaring variables/methods, Scriptlets (<% %>) for embedding Java code, and Expressions (<%= %>) for outputting values. Directives and actions are not considered scripting elements.
B
Correct answer
Explanation
JSP defines exactly three scripting elements: Declarations, Scriptlets, and Expressions. These correspond to the three ways of embedding Java code in JSP pages - for declarations, procedural code, and output expressions respectively.
-
<js>
-
<javascript>
-
<script>
-
<scripting>
C
Correct answer
Explanation
The HTML5 specification defines the `element for embedding or referencing executable client-side scripts, such as JavaScript code. Non-standard elements like<js>,<javascript>, and<scripting>` are unrecognized by modern web browsers and will not execute the enclosed code blocks.
-
"Hello World"
-
document.write("Hello World")
-
response.write("Hello World")
-
("Hello World")
B
Correct answer
Explanation
document.write('Hello World') is valid JavaScript syntax that outputs text directly to the HTML document. This method writes during page parsing and is commonly used for simple output scenarios. Option A is just a string literal without any execution context. Option C uses ASP syntax (response.write), not JavaScript. Option D is syntactically incomplete - just parentheses without a function call.
-
'This is a comment
-
<!--This is a comment-->
-
/This is a comment/
-
//This is a comment
B
Correct answer
Explanation
COBOL is a structured programming language despite its age. Modern COBOL supports structured programming constructs like IF-ELSE, EVALUATE (case-like), PERFORM loops, and modular programming through CALL and nested programs. While early versions had unstructured elements (like GO TO), the language evolved to support structured programming principles.
-
Boston University
-
Arizona State University
-
University of Munich
-
London University
A
Correct answer
Explanation
ATS (Applied Type System) was developed by Hongwei Xi and colleagues at Boston University. It's a programming language designed to support formal verification through advanced type systems, allowing specification and verification of program properties.