0

programming languages Online Quiz - 206

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

Given: class Feline { public static void main(String[] args) { Long x = 42L; Long y = 44L; System.out.print(" " + 7 + 2 + " "); System.out.print(foo() + x + 5 + " "); System.out.println(x + y + foo()); } static String foo() { return "foo"; } } What is the result?

  1. 9 foo47 86foo

  2. 9 foo47 4244foo

  3. 9 foo425 86foo

  4. 9 foo425 4244foo

  5. 72 foo47 86foo

  6. 72 foo425 86foo


Correct Option: F

Which of the following examples correctly defines the macro program Hex?

  1. %macro hex(start=1, stop=10, incr=1); %local i; data null; %do i=&start to &stop by &incr; value=&i; put "Hexadecimal form of &i is " value hex6.; %end; run; %mend hex;

  2. %macro hex(start=1, stop=10, incr=1); %local i; data null; %do i=&start %to &stop %by &incr; value=&i; put "Hexadecimal form of &i is " value hex6.; %end; run; %mend hex;

  3. %macro hex(start=1, stop=10, incr=1); %local i; data null; %do i=&start to &stop by &incr; value=&i; put "Hexadecimal form of &i is " value hex6.; run; %mend hex;

  4. %macro hex(start=1, stop=10, incr=1); %local i; data null; %do i=&start to &stop by &incr; value=&i; put "Hexadeciaml form of &i is " value hex6.; %end run; %mend hex;


Correct Option: B

%let x=5; %let y=10; %let a=%nrstr(%eval(&x + &y)); What is the output of the two put statement %put QCMPRES: %qcmpres(&a); %put CMPRES: %cmpres(&a);

  1. QCMPRES: %eval(&x + &y) CMPRES: 15

  2. CMPRES: 15 QCMPRES: %eval(&x + &y)

  3. QCMPRES: 15 CMPRES: 15

  4. QCMPRES:%eval(&x+&y) CMPRES: 15


Correct Option: A

STRIP(string) returns the same result as :

  1. TRIMN(LEFT(string))

  2. TRIM(LEFT(string))

  3. TRIMN(RIGHT(string))

  4. TRIM(RIGHT(string))


Correct Option: A

What will the following PROC CATALOG step do? proc catalog cat=mylib.sasmacr; contents; quit;

  1. Copy the contents of the Sasmacr catalog to a temporary data set.

  2. List the contents of the Sasmacr catalog as output.

  3. Copy the contents of the output window to the Sasmacr catalog.

  4. none of the above


Correct Option: B

data test ; x="Math A English B Physics A"; y=compress(x,'ABCD','k'); put y; run; The value of 'y' written in log is :

  1. ABA

  2. Math A English B Physics A

  3. a A B A

  4. aABA


Correct Option: A

The SYMPUT routine cannot

  1. be used to assign a data set variable as a value to a macro variable.

  2. create a series of macro variables in one DATA step.

  3. automatically convert a numeric value to a character value when used to assign a value to a macro variable in a DATA step.

  4. be used to assign a numeric value to a macro variable in an SCL (SAS Component Language) program.


Correct Option: D

AI Explanation

To answer this question, we need to understand the SYMPUT routine and its capabilities.

The SYMPUT routine in SAS is used to assign values to macro variables. It is commonly used within a DATA step or a SCL program.

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

Option A) The SYMPUT routine can be used to assign a data set variable as a value to a macro variable. This is possible by using the SYMPUT routine within a DATA step to retrieve the value of a data set variable and assign it to a macro variable.

Option B) The SYMPUT routine can create a series of macro variables in one DATA step. This is possible by using a loop or other iterative process within the DATA step to assign values to multiple macro variables using the SYMPUT routine.

Option C) The SYMPUT routine can automatically convert a numeric value to a character value when used to assign a value to a macro variable in a DATA step. This is true - the SYMPUT routine automatically converts the value to character format before assigning it to the macro variable.

Option D) The SYMPUT routine cannot be used to assign a numeric value to a macro variable in an SCL (SAS Component Language) program. This is the correct answer. In SCL programs, the SYMPUT routine is not available to assign values to macro variables. Instead, you would need to use other methods or functions specific to the SCL language.

Based on the explanations above, the correct answer is D) be used to assign a numeric value to a macro variable in an SCL (SAS Component Language) program.

According to the global symbol table shown here, what value will a reference to &&teach&crs resolve to? TEACH1 Hallis, Dr. George TEACH2 Wickam,Dr. Alice TEACH3 Forest,Mr. Peter CRS 3

  1. &TEACH3

  2. TEACH3

  3. Forest, Mr. Peter

  4. none of the above


Correct Option: C

Which of the following is false?

  1. A %MACRO statement must always be paired with a %MEND statement.

  2. A macro definition can include macro variable references, but it cannot include SAS language statements.

  3. Only macro language statements are checked for syntax errors when the macro is compiled.

  4. Compiled macros are stored in a temporary SAS catalog by default.


Correct Option: B

When you use an %IF-%THEN statement in your macro program

  1. you must place %DO and %END statements around code that describes the conditional action, if that code contains multiple statements.

  2. the %ELSE statement is optional.

  3. you cannot refer to DATA step variables in the logical expression of the %IF statement.

  4. all of the above.


Correct Option: D

data test; a='A dataset'; run; %macro opends(name); %if %sysfunc(exist(&name)) %then %do; %let dsid=%sysfunc(open(&name,i)); %put data set &name; %end; %else %put Data set &name does not exist.; %mend opends; %opends(null); %opends(test); What will be written in the Log?

  1. Data set null does not exist. data set test

  2. data set test Data set null does not exist.

  3. ERROR : null not indentified.

  4. Data set null does not exist. Data set test does not exist.


Correct Option: A

You can avoid re-typing doc comments by being aware of how the Javadoc tool duplicates (inherits) comments for methods that override or implement other methods. This occurs in three cases:

  1. When a method in a class overrides a method in a superclass

  2. When a method in an interface overrides a method in a superinterface

  3. For overridden constructors

  4. When a method in a class implements a method in an interface


Correct Option: A,B,D

What should be the order of the @param tag when there are multiple parameters in the declaration ?

  1. Alphabetical order

  2. Random. No order.

  3. Argument-declaration order

  4. Based on the datatype


Correct Option: C

Which of the following tag is mandatory while using the Javadoc tool ?

  1. @param

  2. @throws

  3. @see

  4. @author


Correct Option: A

Which tag is synonymous to the @throws tag ?

  1. @exception

  2. @throwing

  3. @threw

  4. @except


Correct Option: A

Which tag adds a comment indicating that the API should no longer be used ?

  1. @since

  2. @dontUse

  3. @deprecated

  4. @thows


Correct Option: C

Identify whether the following statement is true or false.
The finally block is executed when an exception is thrown, even if no catch matches it.

  1. True

  2. False


Correct Option: A

AI Explanation

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

Option A) True - This option is correct because the finally block is executed when an exception is thrown, even if no catch matches it. The finally block is a block of code that is always executed, regardless of whether an exception is thrown or not.

Option B) False - This option is incorrect because the statement is actually true. The finally block is executed when an exception is thrown, even if no catch matches it.

The correct answer is A. The finally block is executed when an exception is thrown, even if no catch matches it.

What is the output of the following,
...
StringBuffer sb1 = new StringBuffer("Debopam");
StringBuffer sb2= new StringBuffer("Debopam ");
String ss1 = " Debopam ";
System.out.println(sb1==sb2);
System.out.println(sb1.equals(sb2));
System.out.println(sb1.equals(ss1));
System.out.println("Poddar".substring(3));
...

  1. falsefalsefalsedar

  2. falsetruefalsePoddar

  3. Compiler Error

  4. truetrueFALSEdar


Correct Option: A

What is main objective of Component Based Development (CBD) approach?

  1. Re usability

  2. Portability

  3. Functionality

  4. Efficiency


Correct Option: A

Which of the following is an advantage of CBD?

  1. Re Usable

  2. Low development Cost

  3. Maintainable

  4. All the Above.


Correct Option: D
- Hide questions