41)
abstract class C1{
public void m1(){ //1
}}
abstract class C2{
public void m2(){ //2
}}
compile time error at line1
compile time error at line2
The code compiles fine
None of the above
Explanation:
since the class C2 is abstract it can contain abstract methods
Ans: 3
42)
interface I{
void f1(); // 1
public void f2(); // 2
protected void f3(); // 3
private void f4(); // 4
abstract void f5(); // 5
}
line 1,2,3,4
line 3,4
line 3
line 2,3,4
line 3,4,5
Explanation:
all methods declared within an interface are implicitly public, a weaker access level can not be declared
Ans: 2
43)
abstract class vehicle{
abstract public void speed();
}
class car extends vehicle{
public static void main (String args[])
{
vehicle ob1;
ob1=new car(); //1
}
}
compiletime error at line 1
forces the class car to be declared as abstract
Runtime Exception
None of the above
Explanation:
No Explanation Available
Ans: 2
44)
class command {
public static void main (String[] a1)
{
System.out.println(a1.length());
System.out.println(a1[0]);
System.out.println(a1);
}
}
compile time error at line1
compile time error at line2
compile time error at line3
Runtime exception
Explanation:
length is not a method. it's a variable
Ans: 1
45)
abstract class A {} // 1
transient class B {} // 2
private class C {} // 3
static class D {} // 4
Which of these declarations will not produce a compile-time error?
Ans: 1
Ans: 2
Ans: 3
Ans: 4
None of the above
Explanation:
The modifiers, private and static, can be applied to a nested class, but can not be applied to a class that is not nested transient is allowed only for variables.
Ans: 1
46)
class c1
{
public void m1(Object o1)
{
System.out.println("object");
}
public void m1(String o1)
{
System.out.println("string");
}
public int m1(int c)
{
return c;
}
public static void main(String a[])
{
c1 ob1=new c1();
ob1.m1("hai");
}
}
print object
prints string
compile time error
non of the above
Explanation:
No Explanation Available
Ans: 2
47)
public static double sin(double angle)
What are the units of the "angle" argument?
Degrees
Radians
Both
None of the above
Explanation:
No Explanation Available
Ans: 2
48)
class base
{
base()
{
System.out.println("base");
}
base(int i1)
{
}
}
class Super extends base
{
Super()
{
System.out.println("super");
super(1);
}
public static void main(String [] a)
{
base b1=new Super();
}
}
compile time error
prints base and super
prints super and base
none of the above
Explanation:
No Explanation Available
Ans: 1
49)
The Throwable class is the superclass of all exceptions in the Java language.
true
false
Ans: 1
50)
class C {
private String get ( String str )
{
try
{
throw new Exception ( ) ;
return str ;
}
catch ( Exception e )
{
return null ;
}
}
public static void main ( String peace [ ] ) {
try
{
System.out.println ( ( new C ( ) ).get ( " C " ) ) ;
}
catch ( Exception e )
{
System.out.println( "Exception" ) ;
}
}
};
compile time error
prints Exception
the code compiles and runs fine
none of the above
Ans: 1
abstract class C1{
public void m1(){ //1
}}
abstract class C2{
public void m2(){ //2
}}
compile time error at line1
compile time error at line2
The code compiles fine
None of the above
Explanation:
since the class C2 is abstract it can contain abstract methods
Ans: 3
42)
interface I{
void f1(); // 1
public void f2(); // 2
protected void f3(); // 3
private void f4(); // 4
abstract void f5(); // 5
}
line 1,2,3,4
line 3,4
line 3
line 2,3,4
line 3,4,5
Explanation:
all methods declared within an interface are implicitly public, a weaker access level can not be declared
Ans: 2
43)
abstract class vehicle{
abstract public void speed();
}
class car extends vehicle{
public static void main (String args[])
{
vehicle ob1;
ob1=new car(); //1
}
}
compiletime error at line 1
forces the class car to be declared as abstract
Runtime Exception
None of the above
Explanation:
No Explanation Available
Ans: 2
44)
class command {
public static void main (String[] a1)
{
System.out.println(a1.length());
System.out.println(a1[0]);
System.out.println(a1);
}
}
compile time error at line1
compile time error at line2
compile time error at line3
Runtime exception
Explanation:
length is not a method. it's a variable
Ans: 1
45)
abstract class A {} // 1
transient class B {} // 2
private class C {} // 3
static class D {} // 4
Which of these declarations will not produce a compile-time error?
Ans: 1
Ans: 2
Ans: 3
Ans: 4
None of the above
Explanation:
The modifiers, private and static, can be applied to a nested class, but can not be applied to a class that is not nested transient is allowed only for variables.
Ans: 1
46)
class c1
{
public void m1(Object o1)
{
System.out.println("object");
}
public void m1(String o1)
{
System.out.println("string");
}
public int m1(int c)
{
return c;
}
public static void main(String a[])
{
c1 ob1=new c1();
ob1.m1("hai");
}
}
print object
prints string
compile time error
non of the above
Explanation:
No Explanation Available
Ans: 2
47)
public static double sin(double angle)
What are the units of the "angle" argument?
Degrees
Radians
Both
None of the above
Explanation:
No Explanation Available
Ans: 2
48)
class base
{
base()
{
System.out.println("base");
}
base(int i1)
{
}
}
class Super extends base
{
Super()
{
System.out.println("super");
super(1);
}
public static void main(String [] a)
{
base b1=new Super();
}
}
compile time error
prints base and super
prints super and base
none of the above
Explanation:
No Explanation Available
Ans: 1
49)
The Throwable class is the superclass of all exceptions in the Java language.
true
false
Ans: 1
50)
class C {
private String get ( String str )
{
try
{
throw new Exception ( ) ;
return str ;
}
catch ( Exception e )
{
return null ;
}
}
public static void main ( String peace [ ] ) {
try
{
System.out.println ( ( new C ( ) ).get ( " C " ) ) ;
}
catch ( Exception e )
{
System.out.println( "Exception" ) ;
}
}
};
compile time error
prints Exception
the code compiles and runs fine
none of the above
Ans: 1
No comments:
Post a Comment