Java and SAS Programming Concepts
Test your knowledge of Java programming (StringBuffer, exception handling, Javadoc) and SAS programming (macro language, string functions, PROC CATALOG)
Questions
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?
- 9 foo47 86foo
- 9 foo47 4244foo
- 9 foo425 86foo
- 9 foo425 4244foo
- 72 foo47 86foo
- 72 foo425 86foo
Which of the following examples correctly defines the macro program Hex?
- %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;
- %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;
- %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;
- %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;
%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);
- QCMPRES: %eval(&x + &y) CMPRES: 15
- CMPRES: 15 QCMPRES: %eval(&x + &y)
- QCMPRES: 15 CMPRES: 15
- QCMPRES:%eval(&x+&y) CMPRES: 15
STRIP(string) returns the same result as :
- TRIMN(LEFT(string))
- TRIM(LEFT(string))
- TRIMN(RIGHT(string))
- TRIM(RIGHT(string))
What will the following PROC CATALOG step do? proc catalog cat=mylib.sasmacr; contents; quit;
- Copy the contents of the Sasmacr catalog to a temporary data set.
- List the contents of the Sasmacr catalog as output.
- Copy the contents of the output window to the Sasmacr catalog.
- none of the above
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 :
- ABA
- Math A English B Physics A
- a A B A
- aABA
The SYMPUT routine cannot
- be used to assign a data set variable as a value to a macro variable.
- create a series of macro variables in one DATA step.
- automatically convert a numeric value to a character value when used to assign a value to a macro variable in a DATA step.
- 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
- &TEACH3
- TEACH3
- Forest, Mr. Peter
- none of the above
Which of the following is false?
- A %MACRO statement must always be paired with a %MEND statement.
- A macro definition can include macro variable references, but it cannot include SAS language statements.
- Only macro language statements are checked for syntax errors when the macro is compiled.
- Compiled macros are stored in a temporary SAS catalog by default.
When you use an %IF-%THEN statement in your macro program
- you must place %DO and %END statements around code that describes the conditional action, if that code contains multiple statements.
- the %ELSE statement is optional.
- you cannot refer to DATA step variables in the logical expression of the %IF statement.
- all of the above.
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?
- Data set null does not exist. data set test
- data set test Data set null does not exist.
- ERROR : null not indentified.
- Data set null does not exist. Data set test does not exist.
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:
- When a method in a class overrides a method in a superclass
- When a method in an interface overrides a method in a superinterface
- For overridden constructors
- When a method in a class implements a method in an interface
What should be the order of the @param tag when there are multiple parameters in the declaration ?
- Alphabetical order
- Random. No order.
- Argument-declaration order
- Based on the datatype
Which of the following tag is mandatory while using the Javadoc tool ?
- @param
- @throws
- @see
- @author
Which tag is synonymous to the @throws tag ?
- @exception
- @throwing
- @threw
- @except
Which tag adds a comment indicating that the API should no longer be used ?
- @since
- @dontUse
- @deprecated
- @thows
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.
- True
- False
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));
...
- false<new line>false<new line>false<new line>dar
- false<new line>true<new line>false<new line>Poddar
- Compiler Error
- true<new line>true<new line>FALSE<new line>dar
What is main objective of Component Based Development (CBD) approach?
- Re usability
- Portability
- Functionality
- Efficiency
Which of the following is an advantage of CBD?
- Re Usable
- Low development Cost
- Maintainable
- All the Above.