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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

what is the meaning of the public

A

pubic identifies that this method can be used by any classes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

what is the meaning of static

A

identifies that this method is a class method

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

what the meaning of void

A

the method does not return any value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
  1. 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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

what are legal

  1. int w = (int)888.8;
  2. byte x = (byte)100L;
  3. long y = (byte)100;
  4. byte z = (byte)100L;
    a) 1 and 2
    b) 2 and 3
    c) 3 and 4
    d) All statements are correct
A

d

How well did you know this?
1
Not at all
2
3
4
5
Perfectly