• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Immediate clarification requested

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
////////////////////////////////////////////
=====================================
 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Shyamala,
13)None of them are right. We cann't assign an interger to a char so option A is wrong. Assigning byte to char is also wrong.
byte->short->int->long->float->double
28)B. Your ans is right. Two object are created.
43)A,C. Non static methods can read the static variables.
48)A
Any comments!
Thanks,
Bala
 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
7)b) is not legal because it does not say that it throws the SubException
 
reply
    Bookmark Topic Watch Topic
  • New Topic