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
B
Correct answer
Explanation
Generics were introduced in Java 5 (J2SE 5.0, released in 2004), not in Java 1.4. Java 1.4 was released in 2002 and did not include generic type support. The introduction of generics allowed developers to write type-safe collections and eliminate the need for explicit casting when retrieving objects from collections.
B
Correct answer
Explanation
PHP is a server-side scripting language that executes on the web server, not in the client's browser. Client-side scripting languages like JavaScript run in the browser, while PHP generates HTML that is sent to the client.
A
Correct answer
Explanation
PHP is a loosely typed language, meaning you don't need to declare variable types explicitly. Variables can automatically change types based on the context (e.g., a string can be used in arithmetic operations).
-
NEW_LINE
-
PUT
-
PUT_LINE
-
PUTF
-
None of the above
C
Correct answer
Explanation
PUT_LINE in UTL_FILE package writes text to a file and automatically appends a line terminator (newline character) after each call. PUT writes without any terminator, while PUTF is for formatted output without automatic line termination. NEW_LINE is not a valid UTL_FILE procedure.
-
32767
-
0
-
1024
-
1
-
None of the above
C
Correct answer
Explanation
The default max_linesize parameter in UTL_FILE.FOPEN is 1024 bytes. This parameter controls the maximum line length that can be written to or read from a file. It can be explicitly set up to 32767 bytes if needed for longer lines.
-
NSLog()
-
Printf()
-
System.out.println()
-
Scanf()
A
Correct answer
Explanation
NSLog() is the standard function for logging objects to the console in Objective-C. It works with Objective-C objects and format strings, similar to printf() but specifically designed for Cocoa/Cocoa Touch frameworks. printf() is a C function, System.out.println() is Java, and scanf() is for input.
-
-(void)setPrice:(float)newPrice;
-
-(void)setPrice:float newPrice;
-
-void setPrice:(float)newPrice;
-
-void setPrice:float newPrice;
A
Correct answer
Explanation
Objective-C method declarations require the return type in parentheses after the minus sign. The correct syntax is -(returnType)methodName:(parameterType)parameterName;
-
assign
-
retain
-
readwrite
-
copy
B
Correct answer
Explanation
The 'retain' keyword is used to claim ownership of an object upon assignment. This increments the reference count, ensuring the object stays in memory. Assign doesn't claim ownership, readwrite is about accessor generation, and copy creates a new instance.
B
Correct answer
Explanation
Python was created by Guido van Rossum and first released in 1991. It is known as a general-purpose, very-high level programming language. C# was created by Microsoft (Anders Hejlsberg), Perl by Larry Wall, and Jython is a Python implementation for JVM (not by Guido). The name 'Von Russom' is a typo for 'van Rossum'.
B
Correct answer
Explanation
String objects in Java are immutable and do not have a reverse() method. To reverse a string, you would need to use StringBuilder or convert to a char array, reverse it, and create a new string.
-
The class is fully encapsulated
-
The code demonstrates polymorphism
-
The ownerName variable breaks encapsulation
-
The cardID and limit variables break polymorphism
C
Correct answer
Explanation
Proper encapsulation requires all fields to be private with controlled access through methods. The ownerName field is public, breaking encapsulation. CardID and limit are correctly private. Option A is wrong (not fully encapsulated). Option B is wrong (no polymorphism shown). Option D is wrong (private fields don't break polymorphism).
-
The class is fully encapsulated
-
The code demonstrates polymorphism
-
The ownerName variable breaks encapsulation
-
The cardID and limit variables break polymorphism
C
Correct answer
Explanation
Proper encapsulation requires all fields to be private with access controlled through getters and setters. The ownerName field is declared public, allowing direct external access and modification - this breaks encapsulation regardless of the setter method's presence.
-
Subscripting enables us to write a more compact code in the procedure division.
-
Subscripting enables us to refer to any element of a table by the same data name with the facility of identifying the particular element through the values of subscript
-
Subscripting reduces the number of entries to be included in the data division.
-
Subscripting enables us to use loops in the procedure division.
D
Correct answer
Explanation
The question asks which statement is INCORRECT. Subscripting allows referring to table elements by index, reduces data division entries, and enables compact code. However, subscripting itself is a table access mechanism - it doesn't inherently enable loops (PERFORM with VARYING enables loops). So claiming subscripting enables loops is incorrect.
-
Faster
-
Slower
-
The execution speed is similar
-
All of above
B
Correct answer
Explanation
To solve this question, the user needs to know basic concepts of programming languages and how they are executed.
The answer is:
B. Slower
Scripts are interpreted line by line during runtime, whereas compiled programs are translated into machine language (binary code) before runtime. This means that compiled programs are faster than scripts because they do not require interpretation during runtime. On the other hand, scripts are easier to write, modify, and debug because they do not need to be compiled before execution.
-
Open source general purpose
-
Proprietary general purpose
-
Open source special purpose
-
Proprietary special purpose
A
Correct answer
Explanation
PHP is an open-source, general-purpose scripting language that is especially suited for web development and can be embedded into HTML. The 'open source' designation means the source code is freely available for anyone to use, modify, and distribute. 'General purpose' indicates it's not limited to web-only tasks - PHP can be used for command-line scripting, GUI applications, and more. Option B incorrectly calls it proprietary (it's not owned by a single company), while options C and D incorrectly suggest it's limited to special purposes.