Hi
These are questions found in
http://valiveru.tripod.com/java/jvaltest.html, at the end of each question pls loook for my questions and doubts and kindly clarify them.
Question 7.
Given that method aMethod() throws BaseException, SubException and RuntimeException of the following exception hierarchy
java.lang.Exception
|
+ - - BaseException
|
+ - - SubException
|
+ - - java.lang.RuntimeException
Which of the following are legal
A.public class MyClass {
public void myMethod(){
aMethod();
}
}
B.public class MyClass{
public void myMethod() throws BaseException,RuntimeException{
aMethod();
}
}
C.public class MyClass{
public void myMethod() throws BaseException{
aMethod();
}
}
D.public class MyClass{
public void myMethod() throws Exception{
aMethod();
}
}
E.public class MyClass{
public void myMethod() throws RuntimeException {
aMethod();
}
}
c,d
//////////////////////////
is b not legal ?? why ???
///////////////////////////
==================================================
Question 13.
Select the valid primitive assignments of the following.
A.int i = 10;
char c = i;
B.float f;
long l = 100L;
f = l;
C.short s = 20;
char c = s;
D.byte b = 20;
char c = b;
E.short s1 = 10;
short s2 = 20;
short result = s1*s2;
a,b
/////////////////////////////////
why is d not valid ???
////////////////////////////////
================================================
Question 28.
How many String objects are created when we run the following code.
String s1,s2,s3,s4;
s1 = "Hello";
s2 = s1;
s3 = s2 + "Pal";
s4 = s3;
A.1
B.2
C.3
D.4
E.We can't say.
c
////////////////////////////////
i think b is right bcoz two strings are created
one at s1="Hello" and one at s3=s2+"Pal"
//////////////////////////////
================================================
Question 43.
Which of the follwing is true about static modifier.
A.static can be applied to : instance variables, methods,
code Segments and classes.
B.a static method cannot be overridden.
C.inner classes can be both static & private.
D.a static reference cannot be made through non static
method or code block.
E.abstract & static both can be applied together to a
method.
b,c,d
/////////////////////////////
how is d right ?? actually the viceversa is right ie. non static reference
cannot be made thro static method or code block
//////////////////////////////
===========================================================
Question 48.
Which of the following are true about Layout Managers
A.The component gets its preffered size when we use
FlowLayout to layout the components of container.
B.In BorderLayout, the component at center gets all the
space that is left over, after the components at North &
South have been considered.
C.The method setRowmajor(boolean) is used to set the way
components are layed out(Row/Column after Row/Column)
while using GridLayout.
D.Programmers can use a layout called null layout to place
the components at the coordinate positions he wants.
E.With a GridLayout Manager if they are two many components
to fit in a single row, additional rows are created.
b,d
//////////////////////////////////////////////////
i think there is an error with the answer markings
bcoz d is wrong and e is right.
////////////////////////////////////////////
=====================================