ITSC 1213 CORE MAIN QUESTIONS AND ANSWERS
SET A+
✔✔What will be printed?
int j = 0;
int sum = 0;
for (int i = 0; j < 10; j++) {
sum++;
}
System.out.println(sum); - ✔✔10
✔✔How many times will this loop execute?
for (int x = 5; x >=0; x--) {
...
} - ✔✔6
✔✔Which of the following are characteristics of ArrayLists (select all that apply)? -
✔✔Parameterized types
✔✔Declaring an ArrayList is accomplished by which of the following? -
✔✔ArrayList<String> myList = new ArrayList<String>();
✔✔The number of elements in an ArrayList named myList is found by -
✔✔myList.size();
✔✔Given the following code, how would you add the first element to the ArrayList?
ArrayList<Foo> myList = new ArrayList<Foo>();
Foo f = new Foo(); - ✔✔myList.add(f);
, ✔✔Given an ArrayList of type Bar and of unknown size, how would you remove the
element created by the following statement?
Bar b = new Bar(); - ✔✔if(myList.contains(b)) myList.remove(b);
OR
myList.remove(b);
✔✔Except for classes in the java.lang package, you always have to specify the full
name of every class you want to use in your code. - ✔✔True
✔✔The full name of a class is given by - ✔✔<package_name>.<class_name>
✔✔Which of the following are valid uses of package names? - ✔✔public
java.util.ArrayList<String> s fred() { ...}
OR
import java.util.ArrayList; public class myClass { ... ArrayList<String> s = new
ArrayList<String>; ... }
✔✔ A java class is - ✔✔a blueprint for creating objects
✔✔In object-oriented programming we - ✔✔model real-world "things" or projects in
code
✔✔Javac is a - ✔✔complier
✔✔The hierarchy of code elements in Java is - ✔✔Source -> Class -> Method ->
Statement
✔✔Considering how parameters are used in methods, Java passes everything by -
✔✔argument
✔✔The maximum number of values a method is allowed to return is - ✔✔one and only
one
✔✔The Java equivalent of cout is - ✔✔System.out.println(...);
✔✔In Java, a class - ✔✔defined the operations an object can perform and the
information that object "knows"
✔✔In Java, everything goes in a class - ✔✔True
✔✔In a Java class, the name of a method that can be executed is - ✔✔main
SET A+
✔✔What will be printed?
int j = 0;
int sum = 0;
for (int i = 0; j < 10; j++) {
sum++;
}
System.out.println(sum); - ✔✔10
✔✔How many times will this loop execute?
for (int x = 5; x >=0; x--) {
...
} - ✔✔6
✔✔Which of the following are characteristics of ArrayLists (select all that apply)? -
✔✔Parameterized types
✔✔Declaring an ArrayList is accomplished by which of the following? -
✔✔ArrayList<String> myList = new ArrayList<String>();
✔✔The number of elements in an ArrayList named myList is found by -
✔✔myList.size();
✔✔Given the following code, how would you add the first element to the ArrayList?
ArrayList<Foo> myList = new ArrayList<Foo>();
Foo f = new Foo(); - ✔✔myList.add(f);
, ✔✔Given an ArrayList of type Bar and of unknown size, how would you remove the
element created by the following statement?
Bar b = new Bar(); - ✔✔if(myList.contains(b)) myList.remove(b);
OR
myList.remove(b);
✔✔Except for classes in the java.lang package, you always have to specify the full
name of every class you want to use in your code. - ✔✔True
✔✔The full name of a class is given by - ✔✔<package_name>.<class_name>
✔✔Which of the following are valid uses of package names? - ✔✔public
java.util.ArrayList<String> s fred() { ...}
OR
import java.util.ArrayList; public class myClass { ... ArrayList<String> s = new
ArrayList<String>; ... }
✔✔ A java class is - ✔✔a blueprint for creating objects
✔✔In object-oriented programming we - ✔✔model real-world "things" or projects in
code
✔✔Javac is a - ✔✔complier
✔✔The hierarchy of code elements in Java is - ✔✔Source -> Class -> Method ->
Statement
✔✔Considering how parameters are used in methods, Java passes everything by -
✔✔argument
✔✔The maximum number of values a method is allowed to return is - ✔✔one and only
one
✔✔The Java equivalent of cout is - ✔✔System.out.println(...);
✔✔In Java, a class - ✔✔defined the operations an object can perform and the
information that object "knows"
✔✔In Java, everything goes in a class - ✔✔True
✔✔In a Java class, the name of a method that can be executed is - ✔✔main