Programming Languages Quiz
Questions covering SAS macros, XML, Java programming, and shell scripting fundamentals
Questions
Following test option may be used to check whether the stdin in a given script is a terminal
- [ -t 0 ]
- [ -t 1 ]
- [ -T 0 ]
- [ -T 1 ]
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?
- Flip a Clidlet
- Flip a Clidder
- Flip a Clidder Flip a Clidlet
- Flip a Clidlet Flip a Clidder
- Compilation fails
Given: public abstract interface Frobnicate { public void twiddle(String s) ; } Which is a correct class? (Choose all that apply.)
- public abstract class Frob implements Frobnicate { public abstract void twiddle(String s){} }
- public abstract class Frob implements Frobnicate { }
- public class Frob extends Frobnicate { public void twiddle(Integer i) { } }
- public class Frob implements Frobnicate { public void twiddle(Integer i) { } }
- public class Frob implements Frobnicate { public void twiddle(String i) { } public void twiddle(Integer s) { } }
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?
- BD
- DB
- BDC
- DBC
- Compilation fails
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(); } }
- Clidlet
- Clidder
- Clidder Clidlet
- Clidlet Clidder
- Compilation fails.
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?
- 6
- 7
- 8
- 9
- Compilation fails.
- An exception is thrown.
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.)
- Beagle b2 = (Beagle) dog1;
- Beagle b3 = (Beagle) dog2;
- Beagle b4 = dog2;
- None of the above statements will compile.
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.)
- x2.do2( );
- (Y) x2. do2( );
- ((Y)x2).do2();
- None of the above statements will compile.
Given: 1. class Zing { 2. protected Hmpf h; 3. } 4. class Woop extends Zing { } 5. class Hmpf { } Which is true? (Choose all that apply.)
- Woop is-a Hmpf and has-a zing.
- zing is-a Woop and has-a Hmpf.
- Hmpf has-a Woop and Woop is-a Zing.
- Woop has-a Hmpf and Woop is-a zing.
- Zing has-a Hmpf and Zing is-a Woop.
Which of the following XML goals specifically supports compatibility between applications?
- It should be easy to write programs that process XML documents
- Optional features should be kept to a minimum, ideally zero
- XML documents should be human legible and reasonably clear
- None
The XML declaration is which of the following?
- Optional but makes a document more portable
- Highly discouraged by W3C standards
- Recommended for HTML programming only
- None
Attribute values must always be enclosed by single or double quotes
- parenthesis
- 'greater-than and less-than signs'
- single or double quotes
- brackets
Valid Options for printing the macro variable in %put statement are :
- ALL , AUTOMATIC , USER
- AUTO , SYS , LOCAL
- ALL , LOCAL ,USERDEFINED
- ALL , AUTO , GLOBAL
What is stored in the variable 'myvar' %let myvar=%str(%%%');
- %'
- %%'
- (apostrophe) '
- (percent) %
%SYSFUNC function is used to execute all SAS functions as part of the macro facility.
- True
- False
Executing the statement y=input(x,?? 2.); when variable x is having invalid data will cause the variable ERROR to have value ___ ?
- 1
- 0
- undefined
- any integer value
Which of the following TITLE statements correctly references the macro variable month?
- title "Total Sales for ’&month’ ";
- title "Total Sales for ’month’";
- title "Total Sales for &month";
- title Total Sales for "&month";
What value will these statements assign to the macro variable reptitle: %let area = "Southeast"; %let reptitle = * Sales Report for &area Area *;
- Sales Report for Southeast Area
- Sales Report for "Southeast" Area
- Sales Report for "Southeast" Area
- * Sales Report for "Southeast" Area *
Which of the following statements is false?
- 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.
- Macro variables are always user-defined, and their values remain constant until they are changed by the user.
- Macro variables are text strings that are independent of SAS data sets.
- The values of macro variables can be up to 65,534 characters long.
Which of the following statement is true
- Referencing a nonexistent macro variable results in a warning message. Referencing an invalid macro variable name results in an error message.
- Referencing a nonexistent macro variable results in a error message. Referencing an invalid macro variable name results in an warning message.
- Referencing a nonexistent macro variable and invalid macro variable name results in an error message.
- Referencing a nonexistent macro variable and invalid macro variable name results in an warning message.