0

programming languages Online Quiz - 285

Description: programming languages Online Quiz - 285
Number of Questions: 20
Created by:
Tags: programming languages
Attempted 0/20 Correct 0 Score 0

What statements must be used in order to raise a user-defined exception in PL/SQL?

  1. RAISE

  2. PRAGMA EXCEPTION_INIT

  3. OTHERS

  4. EXCEPTION


Correct Option: A,D

What will be the output of the following: void main() { float a=0.7; if(a<0.7) printf("c++"); else printf("c"); }

  1. c++

  2. c

  3. Compile time error

  4. None of these


Correct Option: A

What will be the output of the following: void main() { char * const ptr="abc"; ptr="xyz"; printf("%s",ptr); }

  1. abc

  2. xyz

  3. Compile time error

  4. None of these


Correct Option: C

What will be the output of the following: void main() { char const *ptr="abc"; ptr="xyz"; printf("%s",ptr); }

  1. None of these

  2. Compile time error

  3. abc

  4. xyz


Correct Option: D

What will be the output of the following: void main() { register int a; printf("%d",a); }

  1. 0

  2. Garbage value

  3. Compile time error

  4. 1


Correct Option: B

What is the use of the double trailing "@@" in an input statement?

  1. loads a new record into the input buffer if an end-of-record is found in the current record

  2. holds the current data line in the buffer for another input statement to process

  3. can be used to read multiple observations from a single data line

  4. is a syntax error


Correct Option: B,C

The following SAS program is submitted: data work.month; date = put('13mar2000'd,ddmmyy10.); run; Which one of the following represents the type and length of the variable DATE in the output data set?

  1. numeric, 8 bytes

  2. numeric, 10 bytes

  3. character, 8 bytes

  4. character, 10 bytes


Correct Option: D

AI Explanation

To answer this question, we need to understand how the PUT function works in SAS and how it affects the variable type and length.

In the given SAS program, the PUT function is used to convert a numeric value (the date '13mar2000'd) into a character value. The format specified in the PUT function is 'ddmmyy10.', which means that the resulting character value will have a length of 10 characters.

Therefore, the variable DATE in the output data set will be of character type and will have a length of 10 bytes.

Let's go through each option to understand why it is correct or incorrect:

Option A) numeric, 8 bytes - This option is incorrect because the variable DATE is converted into a character value using the PUT function, so it will not be of numeric type.

Option B) numeric, 10 bytes - This option is incorrect because the variable DATE is converted into a character value using the PUT function, so it will not be of numeric type.

Option C) character, 8 bytes - This option is incorrect because the length of the variable DATE is specified as 10 characters in the PUT function, so it will have a length of 10 bytes, not 8 bytes.

Option D) character, 10 bytes - This option is correct because the variable DATE is converted into a character value using the PUT function, and the length of the resulting character value is specified as 10 characters.

The correct answer is option D. The variable DATE in the output data set will be of character type and will have a length of 10 bytes.

A raw data file is listed below: --------10-------20-------30 1901 2 1905 1 1910 6 1925 . 1941 1 The following SAS program is submitted and references the raw data file above: data coins; infile 'file-specification'; input year quantity; run; Which one of the following completes the program and produces a non-missing value for the variable TOTQUANTITY in the last observation of the output data set?

  1. totquantity = sum(totquantity + quantity);

  2. totquantity + quantity;

  3. totquantity 0; sum totquantity;

  4. retain totquantity 0; totquantity = totquantity + quantity;


Correct Option: B

AI Explanation

To answer this question, let's go through each option to understand why it is correct or incorrect:

Option A) totquantity = sum(totquantity + quantity);

  • This option is incorrect because the sum function is unnecessary in this context. The sum function is typically used to calculate the sum of multiple variables, but here we only need to add the quantity to the existing value of totquantity.

Option B) totquantity + quantity;

  • This option is correct because it adds the quantity to the existing value of totquantity. By using the "+" operator, the value of totquantity will be updated correctly.

Option C) totquantity 0; sum totquantity;

  • This option is incorrect because it has a syntax error. It seems that the code is trying to assign a value of 0 to totquantity, but the correct syntax should be "totquantity = 0;" instead of "totquantity 0;". Additionally, the "sum" statement is unnecessary in this context.

Option D) retain totquantity 0; totquantity = totquantity + quantity;

  • This option is incorrect because it uses the retain statement, which is not necessary in this case. The retain statement is used to retain the value of a variable across iterations of the data step, but here we don't need to retain the value of totquantity.

The correct answer is B) totquantity + quantity. This option is correct because it adds the quantity to the existing value of totquantity, producing the desired result.

In the following SAS program, the input data files are sorted by the NAMES variable: libname temp 'SAS-data-library'; data temp.sales; merge temp.sales work.receipt; by names; run; Which one of the following results occurs when this program is submitted?

  1. The program executes successfully and a temporary SAS data set is created

  2. The program executes successfully and a permanent SAS data set is created

  3. The program fails execution because the same SAS data set is referenced for both read and write operations

  4. The program fails execution because the SAS data sets on the MERGE statement are in two different libraries


Correct Option: B

AI Explanation

To answer this question, let's go through each option to understand why it is correct or incorrect:

Option A) The program executes successfully and a temporary SAS data set is created - This option is incorrect. The program does create a SAS data set, but it is not temporary.

Option B) The program executes successfully and a permanent SAS data set is created - This option is correct. The program successfully merges the data sets and creates a permanent SAS data set named "sales" in the "temp" SAS data library.

Option C) The program fails execution because the same SAS data set is referenced for both read and write operations - This option is incorrect. The program merges two different data sets, "temp.sales" and "work.receipt", so there is no conflict in referencing the same data set.

Option D) The program fails execution because the SAS data sets on the MERGE statement are in two different libraries - This option is incorrect. The program merges data sets from two different libraries, but this is not an issue for the MERGE statement.

The correct answer is Option B. The program executes successfully and a permanent SAS data set is created because the data sets are merged based on the "names" variable.

The following SAS program is submitted: data work.new; length word $7; amount = 7; if amount = 5 then word = 'CAT'; else if amount = 7 then word = 'DOG'; else word = 'NONE!!!'; amount = 5; run; Which one of the following represents the values of the AMOUNT and WORD variables?

  1. amount word ------ 5 DOG

  2. amount word ------ 5 CAT

  3. amount word ------ 7 DOG

  4. amount word ------ 7 ' ' (missing character value)


Correct Option: A

Which one of the following statements is true regarding the name of a SAS array?

  1. It exists only for the duration of the DATA step.

  2. It is saved with the data set.

  3. It can be used in procedures.

  4. It can be the same as the name of a variable in the data set.


Correct Option: A

The following SAS program is submitted: data work.test; array agent{4} $ 12 sales1 – sales4; run; Which one of the following represents the variables that are contained in the output data set?

  1. SALES1, SALES2, SALES3, SALES4

  2. AGENTS1, AGENTS2, AGENTS3, AGENTS4

  3. None, the DATA step fails because the ARRAY statement can reference only numeric data

  4. None


Correct Option: A

On which portion(s) of a SAS data set does the PRINT procedure report?

  1. the data portion only

  2. the descriptor portion only

  3. the descriptor portion and the data portion

  4. neither the data portion nor the descriptor portion


Correct Option: A

The following SAS program is submitted using the raw data file as input: data work.homework; input name $ age height; if age LE 10; cards; John McCloskey 35 71 June Rosesette 10 43 TinekeJones 9 37 ; run; How many observations will the WORK.HOMEWORK data set contain?

  1. No data set is created as the program fails to execute due to errors

  2. 0

  3. 2

  4. 3


Correct Option: A

The following SAS program is submitted: data allobs; set sasdata.origin (firstobs = 75 obs = 499); run; The SAS data set SASDATA.ORIGIN contains 1000 observations. How many observations does the ALLOBS data set contain?

  1. 425

  2. 424

  3. 499

  4. 1000


Correct Option: A

A raw data record is shown below: 07Jan2002 Which one of the following informats would read this value and store it as a SAS date value?

  1. date9.

  2. ddmonyy9.

  3. ddMMMyy9.

  4. ddmmmyyyy9.


Correct Option: A

Which method will be used to change the datawindow query at runtime?

  1. ModifyQuery()

  2. Modify()

  3. Change()

  4. ChangeQuery()


Correct Option: B

Which is not a Datawindow Buffer?

  1. Primary!

  2. Delete!

  3. Original!

  4. Sort!


Correct Option: D

Which will be the best method to handle DB transactions if number of connections are limited?

  1. SetTransObject()

  2. SetTrans()

  3. SetDBTrans()

  4. SetLimitTrans()


Correct Option: B
- Hide questions