Download 1. Choose the appropriate data type for this value: 5.5 A. int B

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
1.
Choose the appropriate data type for this value: 5.5
A.
int
B.
double
C.
boolean
D.
String
Ans: B
.
2. If you want your condition to depend on two conditions BOTH being true, what is
the proper notation to put between the two Boolean statements ?
A.
&
B.
&&
C.
|
D.
||
Answer: B
3.
An object could be ...
A.
anything
B.
an algorithm
C.
a data container
D.
a program
Answer: A
4. A UML association is ...
A.
implemented as a Java attribute member
B.
implemented as a Java method
C.
implemented as a sub-class
D.
implemented as a String constructor returning the name of the association target
5.
Object-Oriented Programming means ...
A.
Being objective about what you develop
B.
Designing the application based on the objects discovered when analysing the
problem
C.
Writing an algorithm before writing your program and having a test plan
D.
Writing a program composed of Java classes
Answer: B
6.
If classes Student, Staff and Faculty extend class Person, which one makes sense:
A.
Faculty[] faculties={new Person(), new Staff(), new Student()};
B.
Staff[] staff={new Person(), new Faculty(), new Student()};
C.
Person[] persons={new Faculty(), new Staff(), new Student()};
Answer: C
7. Which of the following means that in order for the conditional to happen, either x must be
less than 3 or y must be greater than or equal to 4 ?
A.
if ((x < 3) && (y > 4))
B.
if (x < 3 y >= 4)
C.
if ((x < 3) || (y > = 4))
D.
if ((x > 3) || (y < = 4))
Answer: C
8.Choose the best definition of an object
A.
a thing
B.
an instance of a class
C.
something you wear
Answer: A and B
9. Choose the appropriate data type for this field: isSwimmer
A.
double
B.
boolean
C.
String
D.
int
Answer: C
10. Choose the appropriate data type for this value: "1"
A.
String
B.
boolean
C.
int
D.
char
Answer: A
11.
What is an assignment statement ?
A.
Adding a number to an int
B.
Assigning a multiplication
C.
Assigning a name to a variable
D.
Assigning a value to a variable
Answer: D
12.Which of the following is not a Java keyword?
A.
main
B.
try
C.
integer
D.String
String
Answer: C
13.Integer a = new Integer(2); Integer b = new Integer(2); What happens when you do if
(a==b)?
A.
Compiler error
B.
Runtime Exception
C.
True
D.
False
Answer: D
14. What is the correct syntax for java main method?
A.
public void main(String[] args)
B.
public static void main(string[] args)
C.
public static void main()
D.
none of the above
Answer: D
15.Java keywords are written in lowercase as well as uppercase.
A.
True
B.
False
Answer: B
16. Which is NOT a section of all types of loops ?
A.
Initialization
B.
Loop Body
C.
Test statement
D.
The word "while"
Answer: D
17.In a ‘for’ loop, what section of the loop is not included in the parentheses after “for” ?
A.
Initialization
B.
Loop Body
C.
Test statement
D.
Update
Answer: B
18.Following code will result in: int a1 = 5; double a2 = (float)a1;
A.
Compilation error
B.
Runtime error
C.
No errors
D.Runtime Exception
Answer: C
19. Java runs on _______.
A.
Windows
B.
Unix/Linux
C.
Mac
D.All of the above
Answer: D
20.What is the size of a Char in Java?
A.
4 bits
B.
7 bits
C.
8 bits
D.
16 bits
Answer: D
21.A null reference may be used to access a static variable or method.
A.
True
B.
False
Answer: A
22.Primitive datatypes are allocated on a stack.
A.
True
B.
False
23.
What is a loop ?
A.
A new type of Applet.
B.
A segment of code to be run a specified amount of times
C.
A segment of code to be run infinite times
D.
A segment of code to be run once
Answer: B
24.Can you compare a boolean to an integer?
A.
Yes
B.
No
Answer: B
25.Which one is not correct?
A.
A class needs to be instantiated as an object before being used
B.
An objects exists in memory in run time
C.
Class and object are just different names for the same thing
D.
An object is a variable, where its type is the class used to declare the variable
Answer: C
26.Following code will result in: int num = 6.7;
A.
Compilation error
B.
Runtime error
C.
num being 6.7
D.
num being 6
Answer: A
27.What is essential in making sure that your loop is not infinite ?
A.
That your Boolean statement will at some point be false
B.
That there is a Boolean statement somewhere in your code
C.
That your Boolean statement will at some point be true
D.
All of the choices
Answer: D
28.What displays from the following statements? String word = "abcde"; for (int i = 0; i <4;
i+=2) System.out.print(word[i]);
A.
ab
B.
ac
C.
ace
D.
bd
Answer: B
29.Is Empty .java file name a valid source file name?
A.Yes
B.No
Answer: A
30. What is the default value of the local variables?
A. null
B. 0
C. depends on the data type
D. no default value for local variables
Answer : D