10)
A signed data type has an equal number of non-zero positive and negative values available
1.true
2.false
Answer: 2
Explanation:
The range of negative numbers is greater by 1 than the range of positive numbers
11)
class C{
static int f1(int i) {
System.out.print(i + ",");
return 0;
}
public static void main (String[] args) {
int i = 0;
i = i++ + f1(i);
System.out.print(i);
}}
1)Prints: 0,0
2)Prints: 1,0
3)Prints: 0,1
4)Compile-time error
5)None of the above
Ans: 2
12)
class C{
static String m(int i) {return "int";}
static String m(float i) {return "float";}
public static void main (String[] args) {
long a1 = 1; double b1 = 2;
System.out.print(m(a1)+","+ m(b1));
}}
1)Prints: float,double
2)Prints: float,float
3)Prints: double,float
4)Compile-time error
5)None of the above
Ans: 4
13)
class C
{
public static void main(String a[])
{
C c1=new C();
C c2=m1(c1);
C c3=new C();
c2=c3; //6
anothermethod();
}
static C m1(C ob1){
ob1 =new C();
return ob1;
}
}
After line 6, how many objects are eligible for garbage collection?
1)1
2)2
3)3
4)4
Ans: 2
14)
class c2
{
{
System.out.println("initializer");
}
public static void main(String a[])
{
System.out.println("main");
c2 ob1=new c2();
}
}
1)prints main and initializer
2)prints initializer and main
3)compile time error
4)None of the above
Ans: 1
15)
class c1
{
public static void main(String a[])
{
c1 ob1=new c1();
Object ob2=ob1;
System.out.println(ob2 instanceof Object);
System.out.println(ob2 instanceof c1);
}
}
1)Prints true,false
2)Print false,true
3)Prints true,true
4)compile time error
5)None of the above
Ans: 3
A signed data type has an equal number of non-zero positive and negative values available
1.true
2.false
Answer: 2
Explanation:
The range of negative numbers is greater by 1 than the range of positive numbers
11)
class C{
static int f1(int i) {
System.out.print(i + ",");
return 0;
}
public static void main (String[] args) {
int i = 0;
i = i++ + f1(i);
System.out.print(i);
}}
1)Prints: 0,0
2)Prints: 1,0
3)Prints: 0,1
4)Compile-time error
5)None of the above
Ans: 2
12)
class C{
static String m(int i) {return "int";}
static String m(float i) {return "float";}
public static void main (String[] args) {
long a1 = 1; double b1 = 2;
System.out.print(m(a1)+","+ m(b1));
}}
1)Prints: float,double
2)Prints: float,float
3)Prints: double,float
4)Compile-time error
5)None of the above
Ans: 4
13)
class C
{
public static void main(String a[])
{
C c1=new C();
C c2=m1(c1);
C c3=new C();
c2=c3; //6
anothermethod();
}
static C m1(C ob1){
ob1 =new C();
return ob1;
}
}
After line 6, how many objects are eligible for garbage collection?
1)1
2)2
3)3
4)4
Ans: 2
14)
class c2
{
{
System.out.println("initializer");
}
public static void main(String a[])
{
System.out.println("main");
c2 ob1=new c2();
}
}
1)prints main and initializer
2)prints initializer and main
3)compile time error
4)None of the above
Ans: 1
15)
class c1
{
public static void main(String a[])
{
c1 ob1=new c1();
Object ob2=ob1;
System.out.println(ob2 instanceof Object);
System.out.println(ob2 instanceof c1);
}
}
1)Prints true,false
2)Print false,true
3)Prints true,true
4)compile time error
5)None of the above
Ans: 3