Study Solutions
Which of the following are valid Java Identifiers? Choose all that apply.
00xTrick
Test Variable
a555c
java_&_point
SpEcIaL_vAlUe
sum & difference
Tax
a-javapoint
age1
1AGE ANS a555c
SpEcIaL_vAlUe
Tax
age1
What will be the output of this code?
int x = 10;
int y = 13;
int a = y;
y = x;
x = a;
System.out.print(x); ANS 13
Given the following int (integer) variables, a = 7, b = 1, c = 4, d = 15, evaluate the expression:
a * (b + c) / d + 2 ANS 4
,Evaluate this logical expression:
false || true ANS True
Evaluate this expression:
8 + 6 <= 10 || 10 - 10 > 3 ANS False
Which of the following are NOT Java primitive data types?
class
Random
Math
char
real
int
String
float
boolean
Array ANS class
Random
Math
real
String
Array
When the following expression is evaluated, the result will be what Java data type?
-61f + 49
, 1) int
2) float
3) double
4) boolean
5) char
6) String
7) none of these ANS 2) float
Which of the following would be the best data type for a variable to store the average score on the final exam?
int
none of these
String
boolean
char
float ANS float
Method overloading distinguishes between methods based on _____. ANS parameter types or number of
parameters in a class
The Java keyword used to declare that a method does not return a value is _____. ANS void
A default constructor takes _____ argument(s). ANS 0
A name defined in an outer scope is not available in all blocks nested inside that scope.
True
False ANS False
Encapsulation is about assigning responsibilities to objects.