programming languages Online Quiz - 8
programming languages Online Quiz - 8
Questions
Question 1 Multiple Choice (Single Answer)
What is the output of the below JavaScript?
<script>
var bol = new Boolean();
alert(bol);
</script>
- false
- true
- error
- None of the above
Question 2 Multiple Choice (Single Answer)
What is the output of the below JavaScript?
<script>
var patt1 = new RegExp("e");
alert(patt1.test("This is an example"));
</script>
- false
- true
- e
- 11
Question 3 Multiple Choice (Single Answer)
<script>
var patt1 = new RegExp(/e/g);
alert(patt1.exec("This is an Example"));
</script>
- e
- E
- error
- 16
Question 4 Multiple Choice (Single Answer)
<script>
var str = "This is an Example";
alert(str.match("example"));
</script>
- null
- Example
- example
- error
Question 5 Multiple Choice (Single Answer)
<script>
var str = "This is an Example";
alert(str.search("example"));
</script>
- 11
- -1
- error
- Example
Question 6 Multiple Choice (Single Answer)
<script>
var str = "This is an Example";
alert(str.replace("Example", "Error"));
</script>
- Example
- Error
- This is an Example
- This is an Error
Question 7 Multiple Choice (Single Answer)
<script>
var one = ["a", "b"];
var two = ["c", "d"];
var three = one.concat(two); alert(three);
</script>
- abcd
- a,b,c,d
- c,d,a,b
- error
Question 8 Multiple Choice (Single Answer)
<script>
var one = ["a", "b"];
alert(one.join("&&"));
</script>
- a&&b
- ab&&
- a,b,&&
- error
Question 9 Multiple Choice (Single Answer)
<script>
var one = ["a", "b", "c"];
one.pop();
alert(one);
</script>
- a,b
- b,c
- error
- a,b,c
Question 10 Multiple Choice (Single Answer)
What is the output of the below JavaScript?
<script>
var one = ["a", "b", "c", "d"];
alert(one.slice(-2));
</script>
- error
- a,b
- a,b,c,d
- c,d
Question 11 Multiple Choice (Single Answer)
Given:
public static void before() {
Set set = new TreeSet();
set.add("2");
set.add(3);
set.add("1");
Iterator it = set.iterator();
while (it.hasNext()) System.out.print(it.next() + " ");
}
Which statements are true?
- The before() method will print 1 2
- The before() method will print 1 2 3
- The before() method will print three numbers, but the order cannot be determined
- The before() method will not compile
- The before() method will throw exception at runtime
Question 12 Multiple Choice (Single Answer)
Given:
import java.util.*;
public class Magellan {
public static void main(String[] args) {
TreeMap<String, String> myMap = new TreeMap<String, String>();
myMap.put("a", "apple"); myMap.put("d", "date");
myMap.put("f", "fig"); myMap.put("p", "pear");
System.out.println("1st after mango: " + // sop 1
myMap.higherKey("f"));
System.out.println("1st after mango: " + // sop 2
myMap.ceilingKey("f"));
System.out.println("1st after mango: " + // sop 3
myMap.floorKey("f"));
SortedMap<String, String> sub = new TreeMap<String, String>();
sub = myMap.tailMap("f");
System.out.println("1st after mango: " + // sop 4
sub.firstKey());
}
}
Which of the System.out.println statements will produce the output 1st after mango: p?
- sop 1
- sop 2
- sop 3
- sop 4
- compilation fails
Question 13 Multiple Choice (Multiple Answers)
Given:
class TKO {
public static void main(String[] args) {
String s = "-";
Integer x = 343;
long L343 = 343L;
if(x.equals(L343)) s += ".e1 ";
if(x.equals(343)) s += ".e2 ";
Short s1 = (short)((new Short((short)343)) / (new Short((short)49)));
if(s1 == 7) s += "=s ";
if(s1 < new Integer(7+1)) s += "fly ";
System.out.println(s);
}
}
Which of the following will be included in the output String s? (Choose all that apply.)
- .e1
- .e2
- =s
- fly
Question 14 Multiple Choice (Single Answer)
Given:
import java.util.regex.*;
public class Archie {
public static void main(String[] args) {
Pattern p = Pattern.compile(args[0]);
Matcher m = p.matcher(args[1]);
int count =
while(m.find())
count++;
System.out.print(count);
}
}
And given the command line invocation:java Archie "\d+" ab2c4d67
What is the result?
- 0
- 3
- 4
- 8
- 9
Question 15 Multiple Choice (Single Answer)
Given:
import java.util.*;
public class Looking {
public static void main(String[] args) {
String input = "1 2 a 3 45 6";
Scanner sc = new Scanner(input);
int x = 0;
do {
x = sc.nextInt();
System.out.print(x + " ");
} while (x!=0);
}
}
What is the result?
- 1 2
- 1 2 3 45 6
- 1 2 3 4 5 6
- 1 2 a 3 45 6
- 1 2 followed by an exception
Question 16 Multiple Choice (Single Answer)
SAS stands for
- Statistical Analysis System
- Statistical Analysis Systems
- Statistic Analysis System
- Statestical Analysis System
Question 17 Multiple Choice (Single Answer)
SAS is a
- Low Level Language
- High Level Language
- Machine Level Language
- Binary Level Language
Question 18 Multiple Choice (Single Answer)
SAS is a
- Sixth Generation Language
- Third Generation Language
- Fifth Generation Language
- Fourth Generation Language
Question 19 Multiple Choice (Single Answer)
SAS can be used to
- Data access
- Data management
- Data analysis
- All the above
Question 20 True/False
SAS can't be used for "Data Presentation"
- True
- False