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. join conditions are not specified in a PROC SQL join.

  2. join conditions are not specified in a PROC SQL set operatio

  3. more than two tables are specified in a PROC SQL join.

  4. the keyword ALL is used with the OUTER UNION operator.

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

A Cartesian product occurs when a PROC SQL join is specified without a WHERE clause condition to link the tables, causing every row from one table to combine with every row from the other. Set operations like OUTER UNION operate on rows differently and don't produce Cartesian products.

Multiple choice technology programming languages
  1. 150

  2. 7

  3. 4

  4. 1

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

The query groups by FlightNumber and filters with HAVING to show only the 4 flights where average boarded passengers exceeds 150. The GROUP BY produces 7 groups (one per unique flight), but HAVING filters this to only the 4 matching flights, regardless of total rows.

Multiple choice technology programming languages
  1. The query syntax is not valid.

  2. The outer query must pass values to the subquery before the subquery can return values to the outer query.

  3. PROC SQL will not execute this query when it is submitted.

  4. After the query is submitted, the SAS log will indicate whether the query has valid syntax.

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

The query syntax is invalid because the WHERE clause references columns incorrectly - it compares a string literal to a subquery without proper correlation. Option A correctly identifies this syntax error, while other options make incorrect claims about query behavior.

Multiple choice technology programming languages
  1. the tables being joined must contain the same number of columns.

  2. the tables must be sorted before they are joined

  3. the columns that are specified in a join condition in the WHERE clause must have the same data type.

  4. the columns that are specified in a join condition in the WHERE clause must have the same name.

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

For PROC SQL to perform an inner join, only the columns in the join condition must have compatible data types - they don't need matching names, and tables don't need sorting or equal column counts. Data type compatibility is the fundamental requirement for join operations.

Multiple choice technology programming languages
  1. a maximum of 2 tables or in-line views, but multiple joins can be chained together.

  2. a maximum of 32 tables or 2 in-line views.

  3. a maximum of 32 tables, which includes any tables referenced by an in-line view.

  4. a maximum of 2 tables and 32 columns.

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

PROC SQL inner joins can combine up to 32 tables total, including any tables referenced by in-line views within the query. Options A and B incorrectly limit the number of tables to 2, while Option D incorrectly limits both tables and columns.

Multiple choice technology programming languages
  1. proc sql nodup; select membertype from sasuser.frequentflyers;

  2. proc sql; select distinct(membertype) as MemberType from sasuser.frequentflyers;

  3. proc sql; select unique membertype from sasuser.frequentflyers group by membertype;

  4. proc sql; select distinct membertype from sasuser.frequentflyers;

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

SELECT DISTINCT in PROC SQL removes duplicate values from query output by eliminating rows where all selected columns have identical values. Option A's NODUP syntax is invalid, Option B incorrectly uses DISTINCT as a function, and Option C unnecessarily adds GROUP BY.

Multiple choice technology programming languages
  1. ID Salary Bonus 123 70000 5000 456 80000 7000 978 55000 3500

  2. ID Salary Bonus 123 70000 5000 456 80000 7000 744 . 3500

  3. ID Salary Bonus 123 70000 5000 456 80000 7000 744 55000 3500

  4. ID Salary Bonus 123 70000 5000 456 80000 7000 978 55000 .

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

A right join preserves all rows from the right table (salary), which contains IDs 123, 456, and 978. The bonus table only has matching values for IDs 123 and 456, leaving ID 978 with a null (missing) bonus value in the output.

Multiple choice technology programming languages
  1. Table aliases must be used when referencing identical table names from different libraries.

  2. Table aliases can be referenced by using the keyword AS.

  3. Table aliases (or full table names) must be used when referencing a column name that is the same in two or more tables.

  4. Table aliases must be used when using summary functions.

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

Table aliases are optional when applying summary functions like SUM or AVG unless needed to disambiguate identical column names across multiple joined tables. The other statements correctly describe SQL syntax rules, including using the AS keyword and disambiguating columns.

Multiple choice technology programming languages
  1. WHERE address is missing

  2. WHERE address not exists

  3. WHERE address is null

  4. both a and c

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

In SAS PROC SQL, both IS NULL and IS MISSING are equivalent syntax for identifying missing values. Option D correctly identifies that both conditions work to filter rows with no Address data, while Options A and C each give only one of the two valid syntaxes.

Multiple choice technology programming languages
  1. proc sql; select name, spent, 120-spent as calculated Balance from Company.Absences where balance <= 0;

  2. proc sql; select name, spent, 120-spent as Balance from Company.Absences where calculated balance <= 0;

  3. proc sql; select name, spent, 120-spent as Balance from Company.Absences where balance <= 0;

  4. proc sql; select name, spent, 120-spent as calculated Balance from Company.Absences where calculated balance <= 0;

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

Use the CALCULATED keyword to reference a computed column in the WHERE clause. Option B correctly uses 'where calculated balance <= 0' to filter on the derived Balance column. Options A and C omit the required CALCULATED keyword, while Option D incorrectly places it in the SELECT clause.

Multiple choice technology mainframe
  1. Run time error

  2. Compilation error

  3. 10

  4. -10

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

Subtracting 20 from a PICTURE 99 variable (unsigned, holding 10) results in -10. Since the picture clause lacks a sign identifier 'S' (it is PIC 99, not PIC S99), the negative sign is dropped, leaving the value as unsigned 10. Thus, the resultant value of X remains 10.

Multiple choice technology programming languages
  1. BA

  2. AB

  3. Compilation Error

  4. Null point reference error

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

Perl's destructor (DESTROY) uses reverse order of inheritance. When $obj is destroyed, B's DESTROY runs first (prints 'B'), then it reblesses itself to class A. Then A's DESTROY runs (prints 'A'). The output is 'BA'. No compilation or runtime errors occur.

Multiple choice technology programming languages
  1. 3

  2. 0

  3. Error:Array value out of bound

  4. Null value

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

Perl arrays are 0-indexed. @array = (1,2,3) has indices 0,1,2. Accessing $array[3] is out of bounds. Unlike many languages, Perl returns undef (undefined value) rather than throwing an error. undef prints as empty string, which appears as null/empty. Option D correctly identifies this as null value.