Java Questions1
Java Questions1
class box
int width;
int height;
int length;
int volume;
box()
width = 5;
height = 5;
length = 6;
void volume()
volume = width*height*length;
class constructor_output
obj.volume();
System.out.println(obj.volume);
}
Ans: 150
b)Constructors
b)delete
c)class
d)constructor
b)finalize method
c)static method
d)private method
double a, b;
a = 3.0;
b = 4.0;
System.out.println(c);
Ans: sqrt(25.0)=5.0
s.m1(20,20);
}
}
int width;
int height;
int length;
int volume;
void volume()
volume = width*height*length;
class Output
obj.height = 1;
obj.length = 5;
obj.width = 5;
obj.volume();
System.out.println(obj.volume);
a)0
b)1
c)25
d)26
int x;
int y;
void add(int a)
x = a + 1;
x = a + 2;
class Overload_methods
obj.add(6);
System.out.println(obj.x);
a)5
b)6
c)7
d)8
int width;
int height;
int length;
int volume;
volume = width*height*length;
class Prameterized_method
{
box obj = new box();
obj.height = 1;
obj.length = 5;
obj.width = 5;
obj.volume(3,2,1);
System.out.println(obj.volume);
a)0
b)1
c)6
d)25
Q11.What is the process of defining two or more methods within same class
that have same name but different parameters declaration?
a)Method overloading
b)method overririding
c)method hiding
int width;
int length;
int volume;
area()
{
width=5;
length=6;
void volume()
volume = width*length*height;
class cons_method
obj.volume();
System.out.println(obj.volume);
a)0
b)1
c)30
d)Error
int x;
int y;
boolean isequal()
return(x == y);
class Output
obj.x = 5;
obj.y = 5;
System.out.println(obj.isequal());
a)false
b)true
c)0
d)1
int width;
int length;
int area;
this.width = width;
this.length = length;
class Output
obj.area(5 , 6);
a)0 0
b)5 6
c)6 5
d)5 5
b)Function overloading
c)Function doubling
d)None of the mentioned
array_variable[i] = 'i';
System.out.print(array_variable[i] + "" );
i++;
a)i i i i i
b)0 1 2 3 4
c)i j k l m
char a = 'A';
a++;
System.out.print((int)a);
}
a)66
b)67
c)65
d)64
int g = 3;
System.out.print(++g * 8);
a)25
b)24
c)32
d)33
Q19.Which of these coding types is used for data type characters in Java?
a)ASCII
b)ISO-LATIN-1
c)UNICODE
a)0
b)1
c)true
d)false
double result;
result = 0;
System.out.print(result/6);
}
a)16.34
b)16.566666644
c)16.46666666666667
d)16.46666666666666
b)boolean b2 = ‘false’;
c)boolean b3 = false;
d)boolean b4 = ‘true’
if (var1)
System.out.println(var1);
else
System.out.println(var2);
a)0
b)1
c)true
d)false
Q24.What is the range of short data type(16 bits in memory) in Java?
a)-128 to 127
b)-32768 to 32767
c)-2147483648 to 2147483647
a)162
b)65 97
c)67 95
d)66 98
b)-32768 to 32767
c)-2147483648 to 2147483647
double r, pi, a;
r = 9.8;
pi = 3.14;
a = pi * r * r;
System.out.println(a);
a)301.5656
b)301
c)301.56
d)301.56560000
b)False
b)Inheritance
c)Polymorphism
d)Abstraction