ch 4 methods Flashcards
1
Q
what is the method
A
is a collection of a statments that are grouped together to perform an operation
2
Q
what is the meaning of the public
A
pubic identifies that this method can be used by any classes
3
Q
what is the meaning of static
A
identifies that this method is a class method
4
Q
what the meaning of void
A
the method does not return any value
5
Q
public static void main(String[] args) {
double a;double b;
System.out.println( a=0/0.0);
what is the ouput
A
NaN
6
Q
. What will be the error in the following Java code?
byte b = 50; b = b * 50; a) b cannot contain value 50 b) b cannot contain value 100, limited by its range c) No error in this code d) * operator has converted b * 50 into int, which can not be converted to byte without casting
A
d
7
Q
- If an expression contains double, int, float, long, then the whole expression will be promoted into which of these data types?
a) long
b) int
c) double
d) float
A
c
If any operand is double the result of an expression is double.
8
Q
what are legal
- int w = (int)888.8;
- byte x = (byte)100L;
- long y = (byte)100;
- byte z = (byte)100L;
a) 1 and 2
b) 2 and 3
c) 3 and 4
d) All statements are correct
A
d