Shyamala S

+ Follow
since Sep 12, 2000
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Shyamala S

These are questions found in, 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

+ - - BaseException
+ - - SubException
+ - - java.lang.RuntimeException

Which of the following are legal

A.public class MyClass {
public void myMethod(){

B.public class MyClass{
public void myMethod() throws BaseException,RuntimeException{

C.public class MyClass{
public void myMethod() throws BaseException{

D.public class MyClass{
public void myMethod() throws Exception{

E.public class MyClass{
public void myMethod() throws RuntimeException {
is b not legal ?? why ???

Question 13.

Select the valid primitive assignments of the following. 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;

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;




E.We can't say.

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
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.

i think there is an error with the answer markings
bcoz d is wrong and e is right.
hi marcus,
i too feel the same as Ramesh. i couldnt at the first glance of the explanation note that it is becoz of the method not available in base class... probably you could modify the explanation a bit.
thanks both of you. i now understood this clearly.
Question 25)
Which of the following statements are true?
1) The following statement will produce a result of 1. System.out.println( -1 >>>2);
2) Performing an unsigned left shift (<<<) on a negative number will always produce a negative number result <br /> 3) The following statement will produce a result of zero, System.out.println(1 >>1); <br /> 4) All the integer primitives in java are signed numbers <br /> <br /> Answer to Question 25) <br /> Objective 5.1)<br /> 3) The following statement will produce a result of zero, System.out.println(1 >>1);
Although you might not know the exact result of the operation -1 >>> 2 a knowledge of the way the bits will be shifted will tell
you that the result is not plus 1. (The result is more like 1073741823 ) There is no such Java operator as the unsigned left shift. Although it is normally used for storing characters rather than numbers the char Java primitive is actually an unsigned integer
my doubt is the option 4 specifically asks for integer primitives and the answer explains about char Java primitive char an integer primitive ??
Question 57)
Given the following code
class Base {}
class Agg extends Base{
public String getFields(){
String name = "Agg";
return name;
public class Avf{
public static void main(String argv[]){
Base a = new Agg();
What code placed after the comment //Here will result in calling the getFields method resulting in the output of the string "Agg"?
1) System.out.println(a.getFields());
2) System.out.println(;
3) System.out.println((Base) a.getFields());
4) System.out.println( ((Agg) a).getFields());
4) System.out.println( ((Agg) a).getFields());
The Base type reference to the instance of the class Agg needs to be cast from Base to Agg to get access to its methods.The
method invoked depends on the object itself, not on the declared type. So, a.getField() invokes getField() in the Base class,
which displays Base.
Here Marcus says that method invoked depends on the object itself, not on the declared type, which means the object which is an Agg will invoke its method not the method of the declared type i right in this understanding, pls explain.
yes both the files are in the same directory.

this is actually a snippet from the website
in the link first servlets... section 4 simple html building utilities.
kindly look into it and clarify my doubt.
thank you
23 years ago
It has been included already. Actually i think this is not a problem related to servlets but to general static methods in java classes.
23 years ago
given two classes in seperate source files, the first one compiles without error, but the second file on compilation gives the following error
Undefined variable or class name: ServletUtilities
out.println(ServletUtilities.headWithTitle("Hello WWW")
+ "< BODY>\n" + "< H1>Hello WWW< /H1>\n" + "< /BODY>< /HTML>");</pre>
what is the error ??? kindly help.
<code><pre>public class ServletUtilities{
public static final String DOCTYPE =
"< !DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">";
public static String headWithTitle(String title) {
return(DOCTYPE + "\n" +
"< HTML>\n" +
"< HEAD>< TITLE>" + title + "< /TITLE>< /HEAD>\n");

// Other utilities will be shown later...

import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWWW2 extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out = response.getWriter();
out.println(ServletUtilities.headWithTitle("Hello WWW")
+ "< BODY>\n" + "< H1>Hello WWW< /H1>\n" + "< /BODY>< /HTML>");
[spaces added after every '<' to force parsers to display tags rather than interpret them - Jim]
[This message has been edited by Jim Yingst (edited September 14, 2000).]
23 years ago
28. Given the following code listing:
public class myClass{

//Your Declaration HERE!{
try {;
} catch (IOException e) {
public static void main(String args[]) {
System.out.println("My console application");
System.out.println("(press Enter to exit)");

At the specified location, provide a method declaration with the following properties:
Name: waitForKey
Input Parameters: None
Return Value: None
Visibility: All classes, including subclasses, in the current package.

i thought the answer was protected void waitForKey() but the answer is given as public void waitForKey().... how ??
78. What is the output of the following try�catch block?
public class tryme {
public static void main(String args[]) {

int I;
throw(new Exception("Hello Nurse");
}catch(Exception e){
System.out.println("I am Here");
System.out.println("Hello Nurse!");

A. Hello Nurse!
B. No output
C. I am Here
D. A and C
I think the answer shud be D whereas it is given as C, pls explain
24.Which all lines are part of the output when the following code is
compiled and run. Select all correct answers.

public class test {
public static void main(String args[]) {
for(int i = 0; i < 3; i++) {
for(int j = 3; j <= 0; j--) {
if(i == j) continue;
System.out.println(i + " " + j);

A.0 0
B.0 1
C.0 2
D.0 3
E.1 0
F.1 1
G.1 2
H.1 3
I.2 0
J.2 1
K.2 2
L.2 3
M.3 0
N.3 1
O.3 2
P.3 3
Q.The program does not print anything.
correct answer is q, how ??? is it bcoz the second loop checks for j<=0 ???
thanks guys, this is really news to me