Java Programming OOPs
Questions 181 to 190
181.
|
What
is the printout of the following code?
double
x = 5.5;
int
y = (int)x;
System.out.println("x
is " + x + " and y is " + y);
|
||||||||||
Which
of the following is the correct expression of character 4?
|
|||||||||||
How
many bytes a Java character uses for storing?
|
|||||||||||
Which
of the following assignment statement(s) is/are correct?
I. char
c = 'd';
II. char
c = 100;
III. char c = "d";
IV. char
c = "100";
|
|||||||||||
What
does the expression (int)(76.0252175 * 100) / 100 evaluate to?
|
|||||||||||
Which
of the follows JDK command is correct to run a Java application in
ByteCode.class?
|
|||||||||||
Suppose
you define a Java class as follows:
public
class Test {
}
In
order to compile this program, the source code should be stored in a file
named
|
|||||||||||
Which
of the following statement is not true?
|
|||||||||||
What
is wrong in the following code?
class
TempClass {
int i;
public void TempClass(int j) {
int i = j;
}
}
public
class C {
public static void main(String[] args) {
TempClass temp = new TempClass(2);
}
}
|
|||||||||||
To
declare a constant MAX_LENGTH as a member of the class, you write
|
Answers
181.
|
Answer
: (d)
Reason: The value is x is not changed after the casting.
|
Answer
: (d)
Reason: You have to write '4'.
|
|
Answer
: (b)
Reason: Java characters use Unicode encoding.
|
|
Answer
: (c)
Reason: Choice (B) is also correct, because an int
value can be implicitly cast into a char variable. The Unicode of the
character is the int value. In this case, the character is d
|
|
Answer
: (b)
Reason: Your answer D is incorrect
In
order to obtain 76.02, you have divide 100.0.
|
|
Answer
: (a)
Reason: A is the right choice.
|
|
Answer
: (d)
Reason: Test.java is the name of the source code of
the file.
|
|
Answer
: (b)
Reason: There is no certain rule that at least one
constructor must always be defined explicitly.
|
|
Answer
: (b)
Reason: The program would be fine if the void
keyword is removed from public void TempClass(int j).
|
|
Answer
: (e)
Reason: E is the right way to represent.
|
thank you.
ReplyDeletejava tutorial
java tutorial