Java and SAS Programming Quiz

Test your knowledge of Java and SAS programming languages including syntax, functions, data manipulation, and object-oriented concepts

20 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

Dataset x Rev1 Rev2 Rev3 Rev4 1 3 4 5 data y; set x; z=mean(?); run; Fill in the mean function call.

  1. mean(Rev1-Rev4)
  2. mean(of Rev:)
  3. mean(Rev1 Rev2 Rev3 Rev4)
  4. mean(of Rev1,Rev2,Rev3,Rev3)
Question 2 Multiple Choice (Single Answer)

The function that gives the day of the week is

  1. dayofweek
  2. weekday
  3. dayweek
  4. weeknum
Question 3 Multiple Choice (Single Answer)

The Follwing code will result in a compiler error. Why? class Test { void doStuff() { private int x = 7; this.doMore(x); } }

  1. The use of This; local to a function is illegal
  2. Access modifiers can not be applied to local variables
  3. All classes must be declared public
  4. None of these
Question 4 True/False

A class can be marked 'Abstract' even if has no abstract methods .

  1. True
  2. False
Question 5 Multiple Choice (Single Answer)

Which of the following can be marked Static ? (A)Initialization blocks (B)A class nested within another class, but not within a method

  1. Only A
  2. Only B
  3. None of these
  4. Both A & B
Question 6 True/False

The overriding method CAN throw any unchecked (runtime) exception.

  1. True
  2. False
Question 7 Multiple Choice (Single Answer)

x=input('13mar2010'd,date9.) What is the length and type of the variable x

  1. 8 bytes;Numeric
  2. 9 bytes Numeric
  3. 8 bytes Character
  4. 9 bytes Character
Question 8 Multiple Choice (Single Answer)

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?

  1. catt(' ',x,y,z)
  2. cat(' ',x,y,z)
  3. catx(' ',x,y,z)
  4. x||y||z
Question 9 Multiple Choice (Single Answer)

x=day() y=month() z=year() What is true about these variables

  1. x and y are numeric and z is character
  2. All the variables are numeric
  3. x and z are numeric y is character
  4. All the variables are character
Question 10 Multiple Choice (Single Answer)

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?

  1. 15000,4
  2. 45000,3
  3. 15000, 3
  4. 45000 , 4
Question 11 Multiple Choice (Multiple Answers)

Comma informat removes any embedded

  1. -
  2. %
  3. #
  4. $
Question 12 Multiple Choice (Single Answer)

What is true about the user defind format

  1. stored in sashelp.formats
  2. stored in sasuser.formats
  3. temporary not stored anywhere
  4. Stored in a SAS catalog
Question 13 Multiple Choice (Single Answer)

Choose the correct option for specifying the libname for an excel sheet

  1. libname 'example2.xls' outxls
  2. libname outxls excel 'example2.xls'
  3. libname outxls 'example2.xls'
  4. both 2 and 3
Question 14 Multiple Choice (Multiple Answers)

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)

  1. Case 1 will compile and execute
  2. Case 2 will compile and execute
  3. Case 2 will compile but fail at runtime
  4. Both the Cases wont compile
Question 15 Multiple Choice (Single Answer)

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

  1. s1 and s2 have 2 observations and s3 has no observations
  2. s1 and s2 have 5 observations and s3 has 3 observations
  3. s1,s2,s3 have 3 observations
  4. s1 and s2 have 2 observations and s3 has 3 observations
Question 16 Multiple Choice (Single Answer)

In order to select a particular sheet- Ages in an excel for printing using proc print, select the correct option

  1. proc print data=inxls."Ages$"e;
  2. proc print data=inxls."Ages$"n;
  3. proc print data=inxls."Ages$"s;
  4. proc print data=inxls."Ages$";
Question 17 Multiple Choice (Single Answer)

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?

  1. 2
  2. 1
  3. 3
  4. Error because of :soap
Question 18 Multiple Choice (Single Answer)

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?

  1. 2
  2. 1 2
  3. 2 3
  4. 1 2 3
  5. Compilation fails.
  6. Exception is thrown at runtime
Question 19 Multiple Choice (Single Answer)

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?

  1. args.count
  2. args.length
  3. args.count()
  4. args.length()
  5. args.getLength()
Question 20 Multiple Choice (Single Answer)

which of the statements is incorrect

  1. SAS will read and execute steps simultaneously
  2. A step is completed when the QUIT statement appears
  3. All programming steps begin with either a DATA or PROC keyword
  4. A step is completed when the RUN statement appears