gayathri mukkavilli

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

Recent posts by gayathri mukkavilli

Hi, Can you please explain how to pass and retrieve beans from one jsp to another jsp?
18 years ago
JSP
Hi,
The code in one jsp is:

<% while(e.hasMoreElements())
{
NewTicket ticketBean = (NewTicket) e.nextElement();
%>
<a href="http://localhost:8084/qatts/ticketdetails.jsp">
<%= ticketBean.getTicketID() %> </a>
....

and the code in another ticketdetails.jsp is:

<jsp:useBean id="NewTicketbean" scope="session" type="ticket.NewTicket" class="ticket.NewTicketImpl" />

<i>Ticket ID</i> <% NewTicketbean.getTicketID(); %>

where NewTicket is an interface which is implemented in NewTicketImpl.java

My question is: which ticketid I click that particular ticketdetails should be displayed in ticketdetails.jsp. For that i have to use that particular bean and I used as shown above. I'm not getting the values and not showing any error also. What is wrong with the above code and how should I get the values?
18 years ago
JSP
Hi,

Suppose "Product" is an interface and "ProductImpl" is the class which implements "Product" interface which consists of a constructor
ProductImpl();

Then what does the following statement means
Product prod = new ProductImpl();

Can we give ProductImpl prodimpl = new ProductImpl() ???
what is wrong with the above statement?
Hi,

Suppose "Product" is an interface and "ProductImpl" is the class which implements "Product" interface which consists of a constructor
ProductImpl();

Then what does the following statement means
Product prod = new ProductImpl();

Can we give ProductImpl prodimpl = new ProductImpl() ???
what is wrong with the above statement?
18 years ago
Hi,
Then again after a=b if you give another statement b=a, it is giving error.
if a and b are both refer to the same object then we can give b=a also after a=b, right? Why it is giving error?

class Mytest
{
Mytest a;
Mysubtest b;
a= new Mytest();
b= new Mysubtest();
a=b;
b=a; //giving compile error
// remaining code;
}
class Mysubtest extends Mytest
{}

Thanks for the immediate reply
Hi,
I got a very basic question. Look at the below code.

class Mytest
{
Mytest a;
Mysubtest b;
a= new Mytest();
b= new Mysubtest();
a=b;
// remaining code;
}
class Mysubtest extends Mytest
{}

What happens at a==b statement. Here a and b are both reference variables and if value of b is putting into a, does a and b points to Mysubtest? or a points to Mytest and b points to Mysubtest? and Why?
Hi,
The statement

java -ea -da:com... net.example.LaunchTranslator

means, run net.example.LaunchTranslator with enable assertions for all classes and packages except com and its subpackages. so option 'd' is enabled since it is not come under com and its subpackages.
-da belongs to only com... not belongs to net.example.LaunchTranslator
Hi,
That was my doubt too? How come option c is correct. According to my knowledge only 'd' is enabled so it is the only one answer I guess but given 'c' and 'd' are correct.
Hi sri,
I will explain about the assertions briefly here. If you need more about this you can refer to any java books or websites.

An assertion is a statement in java containing a boolean expression that is assumed to be true when the statement is executed. The system reports an "AssertionError" if the expression evaluates to false. It is used for debugging purposes:

assert(a > 0); // throws an AssertionError if a <= 0

Assertions can be in two forms:


assert Expression1 ;
assert Expression1 : Expression2 ;

Expression1 should always result in a boolean value.

Expression2 can be anything that results in a value. The value is used to generate a String message that displays more debugging information.
For instance:

class AssertionTest
{
int a ;
public void func()
{
assert (a > 0): "a is negative" ;
// Remaining code
}
}

In the above code, the assertion expression is true if a is positive. If a is negative or zero, an AssertionError is thrown with the message "a is negative."

Assertions are disabled by default. To compile with assertions enabled, you need to use the source 1.4 flag:


javac -source 1.4 AssertionTest.java

To enable assertions at runtime, use the -enableassertions or -ea flags.

For selective disabling of assertions at runtime, use the -da or -disableassertions flags.

For enabling assertions in the system classes, use the -esa or -dsa flags. Assertions can also be enabled or disabled on a package basis.

java -ea AssertionTest

Appropriate and inappropriate use of assertions:
You can place an assertion at any location that you don't expect to be reached normally. Assertions can be used to validate the parameters passed to a private method. However, assertions should not be used to validate parameters passed to public methods because a public method must check its arguments regardless of whether assertions are enabled or not. However, you can test postconditions with assertions in both public and non-public methods. Also, assertions should not change the state of a program in any manner.

Hope you understand and let me know if you have any questions.
Good luck
Now I understand. Thanks for your clear explanation.
Hi,
Can anybody tell what is the difference between the following two sets of statements regarding references and values?

set 1:
String s1 = "abc";
String s2 = "abc";
set 2:
String s3 = "abc";
String s4 = new String("abc");

According to my understanding, references are different and values are same
in both the sets. what do you say?
Hi shah,
In Q1: asked to select two. But read that "assert:false" is legal.
So options 'c' and 'd' are legal but not correct?

in Q2: answers are 'c' and 'd'

Thanks
Hi All,
I have two questions on assertions. These are in Khalid & Rolf Book.

Q1: Assuming assertions are enabled, which of these assertion statements will throw an error?

a. assert true:true;
b. assert true:false;
c. assert false:true;
d. assert false:false;

Can you explain this?

Q2: Given the following command, which classes would have assertions enabled?
java -ea -da:com... net.example.LaunchTranslator

a: com.example.Translator
b: java.lang.String
c: dot.com.Boom
d: net.example.LaunchTranslator
e: java.lang.AssertionError

I know that SystemClasses are disabled. so options 'b' and 'e' are disabled. option 'd' is exactly what is given in the statement so it is enabled.
Given that classes in the com package and its subpackages are disabled so options 'a' and 'c' are also disabled. Is it correct? But given option 'c' is enabled. How come option 'c' is enabled?
Does it mean the result of int shift is always between 0 and 31 and the result of long shift is always between 0 and 63?
if so, -12 >>> 8 is giving as 16777215.

I didn't get your point. Can you explain this more clearly?

Thank you very much for your support
With out converting integers into binary can we use the shift operator evalutions using the formulas below always? or better convert into binary and use the shift operators. Coverting into binary is time consuming I guess in the exam.

x >>y = (int) x/2^y (if x is greater than y else always zero)
-x >>y = (int) -x/2^y (if x is greater than y else always -1)
x << y = x * 2^y
-x << y = -x * 2^y
x >>>y = x/2^y

If so, what if y is negative? and (-x >>>y)?