Tag: programming languages

Questions Related to programming languages

Multiple choice technology programming languages
  1. proc sql; update work.frequentflyers set pointsearned=pointsearned* case if milestraveled < 10000 then 1.5 if milestraveled >= 10000 then 2 else 1 end;

  2. proc sql; update work.frequentflyers set pointsearned=pointsearned* case when milestraveled < 10000 then 1.5 when milestraveled >= 10000 then 2 else 1 end;

  3. proc sql; update work.frequentflyers set pointsearned=pointsearned* case if milestraveled < 10000 then pointsearned*1.5 if milestraveled >= 10000 then pointsearned*2 else 1 end;

  4. proc sql; update work.frequentflyers set pointsearned=pointsearned* case if milestraveled < 10000 then pointsearned*1.5 if milestraveled >= 10000 then pointsearned*2 else pointsearned*1 end;

Reveal answer Fill a bubble to check yourself
B Correct answer
Multiple choice technology programming languages
  1. You can call a method on null: x.m() will not throw an error when x is null and m is a static method.

  2. null instanceof Object returns true

  3. You can pass null as the literal argument to a constructor of an anonymous inner class. e.g., new SomeClass(null) { }

  4. None of above

Reveal answer Fill a bubble to check yourself
A Correct answer
Multiple choice technology programming languages
  1. Adding state variables breaks referential transparency (you no longer can understand a statement or expression on its own: you need to understand it in the context of the settings of the global variables)

  2. State variables lessen the cohesion of a program: you need to know more to understand how something works. A major point of Object-Oriented programming is to break up global state into more easily understood collections of local state.

  3. When you add one variable, you limit the use of your program to one instance. What you thought was global, someone else might think of as local: they may want to run two copies of your program at once.

  4. All of above

Reveal answer Fill a bubble to check yourself
D Correct answer