DATA TYPES, VARIABLES AND ARRAYS ONE LINER PART 2
1) What is a string?
Ans: A combination of characters is called as string.
2) Strings are instances of the class String.
a)True b)False
Ans: a.
3) When a string literal is used in the program, Java automatically creates instances of the string class.
a)True
Ans: A combination of characters is called as string.
2) Strings are instances of the class String.
a)True b)False
Ans: a.
3) When a string literal is used in the program, Java automatically creates instances of the string class.
a)True
b)False
Ans: a.
4) Which operator is to create and concatenate string?
Ans: Addition operator(+).
5) Which of the following declare an array of string objects?
a)String[ ] s
Ans: a.
4) Which operator is to create and concatenate string?
Ans: Addition operator(+).
5) Which of the following declare an array of string objects?
a)String[ ] s
b)String [ ]s:
c)String[ s]:
d)String s[ ]:
e) a, b, and d
Ans : e
6) What is the value of a[3] as the result of the following array declaration?
a)1
Ans : e
6) What is the value of a[3] as the result of the following array declaration?
a)1
b)2
c)3
d)4
Ans : d
7) Which of the following are primitive types?
a)byte
Ans : d
7) Which of the following are primitive types?
a)byte
b)String
c)integer
d)Float
Ans : a.
8) What is the range of the char type?
a)0 to 216
Ans : a.
8) What is the range of the char type?
a)0 to 216
b)0 to 215
c)0 to 216-1
d)0 to 215-1
Ans. d
9) What are primitive data types?
Ans : byte, short, int, long
float, double
boolean
char
10) What are default values of different primitive types?
Ans : int - 0
short - 0
byte - 0
long - 0 l
float - 0.0 f
double - 0.0 d
boolean - false
char - null
11) Converting of primitive types to objects can be explicitly.
a)True
Ans. d
9) What are primitive data types?
Ans : byte, short, int, long
float, double
boolean
char
10) What are default values of different primitive types?
Ans : int - 0
short - 0
byte - 0
long - 0 l
float - 0.0 f
double - 0.0 d
boolean - false
char - null
11) Converting of primitive types to objects can be explicitly.
a)True
b)False
Ans: b.
12) How do we change the values of the elements of the array?
Ans : The array subscript expression can be used to change the values of the elements of the array.
13) What is final varaible?
Ans : If a variable is declared as final variable, then you can not change its value. It becomes constant.
14) What is static variable?
Ans : Static variables are shared by all instances of a class.
Ans: b.
12) How do we change the values of the elements of the array?
Ans : The array subscript expression can be used to change the values of the elements of the array.
13) What is final varaible?
Ans : If a variable is declared as final variable, then you can not change its value. It becomes constant.
14) What is static variable?
Ans : Static variables are shared by all instances of a class.
No comments:
Post a Comment