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
-
Runtime error.
-
Depends on the code where you use
-
Compiles Fine
-
Compilation error.
D
Correct answer
Explanation
In Java, generics are invariant. A List reference cannot be assigned an ArrayList instance because a List is not a supertype of List. This mismatch results in a compilation error.
B
Correct answer
Explanation
Dennis Ritchie invented the C programming language at Bell Labs in 1972. C++ was later created by Bjarne Stroustrup, while Java was created by James Gosling.
D
Correct answer
Explanation
Simula, introduced in 1967, is considered the first object-oriented programming language. It introduced key OOP concepts like classes, objects, inheritance, and subclasses. C++ (1979) and Java (1995) came much later. C is not object-oriented.
A
Correct answer
Explanation
Java was named after Java coffee, a type of coffee from Indonesia. The Java logo features a coffee cup. This is a well-known fact in programming history - the name was chosen during a brainstorming session at a coffee shop.
B
Correct answer
Explanation
Dennis Ritchie invented the C programming language at Bell Labs in 1972. C is a foundational language that influenced many later languages including C++, Java, and Python. C++ was developed later by Bjarne Stroustrup.
-
Compilation Error
-
Some Unknown Random Number
-
5
-
I Dont Know
B
Correct answer
Explanation
The printf statement uses %u format specifier with ThatsMyFunction without parentheses, so it prints the function's memory address (a random-looking number) instead of calling it. To print the return value 5, you need ThatsMyFunction(). The %u format expects unsigned int, and a function pointer address fits this.
-
ASCII Table - twice
-
Segmentation fault
-
I hate this Quiz and I dont know it
-
Compilation Error
-
HelloA
-
HelloB
-
HelloABCD
-
HelloD
-
HelloC
-
Compilation Error
D
Correct answer
Explanation
Multi-character constants like 'ABCD' store multiple bytes in an int. The value is implementation-defined, but most compilers store characters in memory order, so 'ABCD' typically evaluates to the last character 'D' (or the integer representing the bytes). The switch matches case 'D', printing HelloD.
-
Compilation Error - Cannot define Function inside Function
-
50
-
Cant say
-
Some Random Number
B
Correct answer
Explanation
Nested functions (functions defined inside other functions) are a GCC extension, not standard C. When compiled with GCC, this code works correctly and prints 50. Standard C compilers would reject this, but the question assumes GCC compilation based on the correct answer being 50.
-
I have started hating C now!!
-
Hello
-
Compilation Error - Cannot return when return type is Void
-
Hello World
-
Segmentation fault
B
Correct answer
Explanation
The printf("Hello") executes first, printing Hello. The return 5 statement then exits the function immediately - code after return is unreachable. While standard C prohibits return with a value in void functions, GCC allows it as an extension. The output is just Hello.
-
5 50 40 30 20 10
-
5 Followed by Random Numbers
-
5 4 3 2 1
-
Segmentation Fault
D
Correct answer
Explanation
This complex compound assignment evaluates right-to-left with operator precedence. i/=i equals 1 (integer division). Then i-=1 makes i=4. i*=4 makes i=16. Finally i+=16 makes i=32. The key is tracking each step carefully with operator precedence.
-
Clear
-
Write
-
Execute
-
Flush
C
Correct answer
Explanation
The Response object in ASP.NET includes Clear, Write, Flush, Redirect, and End methods, but Execute is not a member. Execute is actually a method of the Server object (Server.Execute) which transfers execution to another page. The Response object handles sending output to the client, while Server.Execute handles page transfer. This distinction is important for understanding ASP.NET's object model.
-
$_GET
-
$_POSTS
-
$_GETS
-
All the above
A
Correct answer
Explanation
$_GET is the PHP superglobal array that contains query parameters passed through the URL after the ? character. The other options are wrong - $_POST (not $_POSTS) contains POST request data, and $_GETS doesn't exist as a PHP superglobal. Query parameters in URLs are automatically parsed into $_GET.
-
session_start()
-
session_init()
-
session_boot()
-
None of the Above
A
Correct answer
Explanation
session_start() is the correct PHP function to initialize a session - it must be called before any output is sent to the browser. The other options don't exist - session_init() and session_boot() are not valid PHP functions. Once started, session data becomes available through the $_SESSION superglobal.