Java and SAS Programming Quiz
Test your knowledge of Java and SAS programming languages including syntax, functions, data manipulation, and object-oriented concepts
Questions
Dataset x Rev1 Rev2 Rev3 Rev4 1 3 4 5 data y; set x; z=mean(?); run; Fill in the mean function call.
- mean(Rev1-Rev4)
- mean(of Rev:)
- mean(Rev1 Rev2 Rev3 Rev4)
- mean(of Rev1,Rev2,Rev3,Rev3)
The function that gives the day of the week is
- dayofweek
- weekday
- dayweek
- weeknum
The Follwing code will result in a compiler error. Why? class Test { void doStuff() { private int x = 7; this.doMore(x); } }
- The use of This; local to a function is illegal
- Access modifiers can not be applied to local variables
- All classes must be declared public
- None of these
A class can be marked 'Abstract' even if has no abstract methods .
- True
- False
Which of the following can be marked Static ? (A)Initialization blocks (B)A class nested within another class, but not within a method
- Only A
- Only B
- None of these
- Both A & B
The overriding method CAN throw any unchecked (runtime) exception.
- True
- False
x=input('13mar2010'd,date9.) What is the length and type of the variable x
- 8 bytes;Numeric
- 9 bytes Numeric
- 8 bytes Character
- 9 bytes Character
x='Hi' y='Everybody' z='Hello' The value of z should be "Hi Everyone Hello" Which of the below options can be used to generate this?
- catt(' ',x,y,z)
- cat(' ',x,y,z)
- catx(' ',x,y,z)
- x||y||z
x=day() y=month() z=year() What is true about these variables
- x and y are numeric and z is character
- All the variables are numeric
- x and z are numeric y is character
- All the variables are character
banks {x y} {1 A} {2 B} {3 C} data newbank; set banks; do year=1 to 3; capital + 5000; end; run; What is the value of capital and year for the last observation?
- 15000,4
- 45000,3
- 15000, 3
- 45000 , 4
Comma informat removes any embedded
- -
- %
- #
- $
What is true about the user defind format
- stored in sashelp.formats
- stored in sasuser.formats
- temporary not stored anywhere
- Stored in a SAS catalog
Choose the correct option for specifying the libname for an excel sheet
- libname 'example2.xls' outxls
- libname outxls excel 'example2.xls'
- libname outxls 'example2.xls'
- both 2 and 3
Consider a Base Class 'A' and a Derived Class 'B'. Case 1 B b=new B(); A a= A(b); Case 2 A a=new A(); B b=B(a); Choose the correct option(s)
- Case 1 will compile and execute
- Case 2 will compile and execute
- Case 2 will compile but fail at runtime
- Both the Cases wont compile
dataset new {x y} {1 2} {6 4} {7 5} data s1 s2 s3; set new; if x > 5 then output s1; if y < 5 then output s2; output; run; Choose the correct answer about s1 s2 and s3
- s1 and s2 have 2 observations and s3 has no observations
- s1 and s2 have 5 observations and s3 has 3 observations
- s1,s2,s3 have 3 observations
- s1 and s2 have 2 observations and s3 has 3 observations
In order to select a particular sheet- Ages in an excel for printing using proc print, select the correct option
- proc print data=inxls."Ages$"e;
- proc print data=inxls."Ages$"n;
- proc print data=inxls."Ages$"s;
- proc print data=inxls."Ages$";
sales product qty soap-t1 20 comb 10 oil 20 soap-t2 30 soap-t3 20 How many observations will be present in the newsale dataset?
- 2
- 1
- 3
- Error because of :soap
public class Test { public static void main(String [] args) { int x =5; boolean b1 = true; boolean b2 = false; if((x==4) && !b2) System.out.print(”l “); System.out.print(”2 “); if ((b2 = true) && b1) System.out.print(”3 “); } } What is the result?
- 2
- 1 2
- 2 3
- 1 2 3
- Compilation fails.
- Exception is thrown at runtime
public class Counter { public static void main(String[] args) { int numArgs = /* insert code here */; } } and the command line: java Counter one fred 42 Which code, inserted at line 3, captures the number of arguments passed into the program?
- args.count
- args.length
- args.count()
- args.length()
- args.getLength()
which of the statements is incorrect
- SAS will read and execute steps simultaneously
- A step is completed when the QUIT statement appears
- All programming steps begin with either a DATA or PROC keyword
- A step is completed when the RUN statement appears