Programming Languages Quiz

Questions covering SAS macros, XML, Java programming, and shell scripting fundamentals

20 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

Following test option may be used to check whether the stdin in a given script is a terminal

  1. [ -t 0 ]
  2. [ -t 1 ]
  3. [ -T 0 ]
  4. [ -T 1 ]
Question 2 Multiple Choice (Multiple Answers)

Given: class Clidders { public final void flipper() { System.out.println("Clidder"); } } public class Clidlets extends Clidders { public void flipper() { System.out.println("Flip a Clidlet"); super.flipper(); } public static void main(String [] args) { new Clidlets().flipper(); } } What is the result?

  1. Flip a Clidlet
  2. Flip a Clidder
  3. Flip a Clidder Flip a Clidlet
  4. Flip a Clidlet Flip a Clidder
  5. Compilation fails
Question 3 Multiple Choice (Multiple Answers)

Given: public abstract interface Frobnicate { public void twiddle(String s) ; } Which is a correct class? (Choose all that apply.)

  1. public abstract class Frob implements Frobnicate { public abstract void twiddle(String s){} }
  2. public abstract class Frob implements Frobnicate { }
  3. public class Frob extends Frobnicate { public void twiddle(Integer i) { } }
  4. public class Frob implements Frobnicate { public void twiddle(Integer i) { } }
  5. public class Frob implements Frobnicate { public void twiddle(String i) { } public void twiddle(Integer s) { } }
Question 4 Multiple Choice (Multiple Answers)

Given: class Top { public Top(String s) { System.out.print("B"); } } public class Bottom2 extends Top { public Bottom2(String s) { System.out.print("D"); } public static void main(String [] args) { new Bottom2("C"); System.out.println(" "); } } What is the result?

  1. BD
  2. DB
  3. BDC
  4. DBC
  5. Compilation fails
Question 5 Multiple Choice (Multiple Answers)

Given: class Clidder { private final void flipper() { System.out.println ("Clidder"); } } public class Clidlet extends Clidder { public final void flipper() { System.out.println("Clidlet"); } public static void main(String [] args) { new Clidlet().flipper(); } }

  1. Clidlet
  2. Clidder
  3. Clidder Clidlet
  4. Clidlet Clidder
  5. Compilation fails.
Question 6 Multiple Choice (Multiple Answers)

Given: class Uber { static int y = 2; Uber(int x) { this(); y = y * 2; } Uber() { y++; } } class Minor extends Uber { Minor() { super(y); y = y + 3; } public static void main(String [] args) { new Minor(); System.out.println(y); } } What is the result?

  1. 6
  2. 7
  3. 8
  4. 9
  5. Compilation fails.
  6. An exception is thrown.
Question 7 Multiple Choice (Multiple Answers)

Given: 1. class Dog { } 2. class Beagle extends Dog { } 3. 4. class Kennel { 5. public static void main(String [] arfs) { 6. Beagle bl = new Beagle(); 7. Dog dogl = new Dog(); 8. Dog dog2 = bl; 9. // insert code here 10. } } Which, inserted at line 9, will compile? (Choose all that apply.)

  1. Beagle b2 = (Beagle) dog1;
  2. Beagle b3 = (Beagle) dog2;
  3. Beagle b4 = dog2;
  4. None of the above statements will compile.
Question 8 Multiple Choice (Multiple Answers)

Given the following, 1. class X { void dol() { } } 2. class Y extends X { void do2() { } } 3. 4. class Chrome { 5. public static void main(String [] args) { 6. X x1 = new X(); 7. X x2 = new Y(); 8. Y y1 = new Y(); 9. // insert code here 10. } Which, inserted at line 9, will compile? (Choose all that apply.)

  1. x2.do2( );
  2. (Y) x2. do2( );
  3. ((Y)x2).do2();
  4. None of the above statements will compile.
Question 9 Multiple Choice (Multiple Answers)
  1. Given:    1. class Zing {  2.   protected Hmpf h;  3. }  4. class Woop extends Zing { }  5. class Hmpf { }    Which is true? (Choose all that apply.)
    
  1. Woop is-a Hmpf and has-a zing.
  2. zing is-a Woop and has-a Hmpf.
  3. Hmpf has-a Woop and Woop is-a Zing.
  4. Woop has-a Hmpf and Woop is-a zing.
  5. Zing has-a Hmpf and Zing is-a Woop.
Question 10 Multiple Choice (Single Answer)

Which of the following XML goals specifically supports compatibility between applications?

  1. It should be easy to write programs that process XML documents
  2. Optional features should be kept to a minimum, ideally zero
  3. XML documents should be human legible and reasonably clear
  4. None
Question 11 Multiple Choice (Single Answer)

The XML declaration is which of the following?

  1. Optional but makes a document more portable
  2. Highly discouraged by W3C standards
  3. Recommended for HTML programming only
  4. None
Question 12 Multiple Choice (Single Answer)

Attribute values must always be enclosed by single or double quotes

  1. parenthesis
  2. 'greater-than and less-than signs'
  3. single or double quotes
  4. brackets
Question 13 Multiple Choice (Single Answer)

Valid Options for printing the macro variable in %put statement are :

  1. ALL , AUTOMATIC , USER
  2. AUTO , SYS , LOCAL
  3. ALL , LOCAL ,USERDEFINED
  4. ALL , AUTO , GLOBAL
Question 14 Multiple Choice (Single Answer)

What is stored in the variable 'myvar' %let myvar=%str(%%%');

  1. %'
  2. %%'
  3. (apostrophe) '
  4. (percent) %
Question 15 True/False

%SYSFUNC function is used to execute all SAS functions as part of the macro facility.

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

Executing the statement y=input(x,?? 2.); when variable x is having invalid data will cause the variable ERROR to have value ___ ?

  1. 1
  2. 0
  3. undefined
  4. any integer value
Question 17 Multiple Choice (Single Answer)

Which of the following TITLE statements correctly references the macro variable month?

  1. title "Total Sales for ’&month’ ";
  2. title "Total Sales for ’month’";
  3. title "Total Sales for &month";
  4. title Total Sales for "&month";
Question 18 Multiple Choice (Single Answer)

What value will these statements assign to the macro variable reptitle: %let area = "Southeast"; %let reptitle = * Sales Report for &area Area *;

  1. Sales Report for Southeast Area
  2. Sales Report for "Southeast" Area
  3. Sales Report for "Southeast" Area
  4. * Sales Report for "Southeast" Area *
Question 19 Multiple Choice (Single Answer)

Which of the following statements is false?

  1. A macro variable can be defined and referenced anywhere in a SAS program except within data lines. within the data lines of a DATALINES statement.
  2. Macro variables are always user-defined, and their values remain constant until they are changed by the user.
  3. Macro variables are text strings that are independent of SAS data sets.
  4. The values of macro variables can be up to 65,534 characters long.
Question 20 Multiple Choice (Single Answer)

Which of the following statement is true

  1. Referencing a nonexistent macro variable results in a warning message. Referencing an invalid macro variable name results in an error message.
  2. Referencing a nonexistent macro variable results in a error message. Referencing an invalid macro variable name results in an warning message.
  3. Referencing a nonexistent macro variable and invalid macro variable name results in an error message.
  4. Referencing a nonexistent macro variable and invalid macro variable name results in an warning message.