This week's book giveaway is in the Reactive Progamming forum.
We're giving away four copies of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams and have Adam Davis on-line!
See this thread for details.
Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!

Tayal Rohit

Greenhorn
+ Follow
since Feb 18, 2005
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 Tayal Rohit

thanks a lot.

and whats the major lazy loading?
How we can implement Caching of data using Hibernate 3 ?

Example will be good to help.
Whats are the differences or advantages of one over another in Weblogic and websphere App Servers.


Please count some,.
interview questions,

1 .What will you do if ur web application is slow , what are the area u will check for to find out why ur web application is slow, and how will you resolve them.

and why http procol is called as state less.

2. What does an explain command do in sql how to use it.



thanks

rohit
14 years ago
How you can set a counter in a jsp , that can tell u , how many times that jsp get called.

[Bear edit: better subject title]
[ March 07, 2005: Message edited by: Bear Bibeault ]
14 years ago
JSP
What is the difference between factory design pattern and abstract factory design pattern, please elaborate with examples too.

thanks
please elaborate with answers. I am new to this technology and only have very little idea what it does, so please give me answers too.

thanks.
14 years ago
Hi all

i have to face an interview in web services technology, can any one pass me some questions what are asked in web services realted technology.

thanks

rohit
14 years ago
Q. What is class lodaer ? How it works in web sphere app server.
please put some light on this topic.


Thanks in advance.
14 years ago
finalize() used to garbage collect also, becoz we cant say about gc wen it do garbage collection.in finalize() we can make the object candidate for garbage collection.
Hello Please send em some information about MQ Series , how it is used and where it fits in web application ? basically where its used most , what kind of application it benefit mostly.

Thanks in advance.

HaAe a great day.
Can any one answer a question i found in a test , but not sure of answer.the last questions*(no -6) and please reply if u r agree with the answers i gave.

1.What is the output of the following class? Briefly explain your answer.

public class Bar {
private static String a;
private static void foo(String a){
a = "second";
}
public static void main(String[] argv){
a = "first";
System.out.println(a);
foo(a);
System.out.println(a);
}
}



First
Second

In method main � first out put statement will print the value of a
And after that foo() get calles that changed the value of a = �second�.


2.Override java.lang.Object.equals in the following class, so that equality is based on values rather than references.

public class Simple {
private int digits;
private String text;

public Simple(int i, String s) {
digits = i;
text = s;
}
}


public boolean equals(Object a)
{
boolean res = true;
try
{
Simple aCast = (Simple)a;

If(this.digits!=aCast.digits)
{
res= false;
}
If(!this.test.equals(aCast.a))
{
res= false;
}
}catch(ClasCastException cce)
{
res = false;
}
return false;

}
}



3.What is the output of the following? Briefly explain your answer.

public class Test4 {

static void doHelloGoodbye(Base b){
b.greeting();
b.farewell();
}

public static void main(String args[]){
Sub s = new Sub();
doHelloGoodbye(s);
}
}


class Base{
static void greeting(){
System.out.println("Hello");
}
void farewell(){
System.out.println("Goodbye");
}
}

class Sub extends Base{
static void greeting(){
System.out.println("Hi");
}
void farewell(){
System.out.println("See ya!");
}
}


Hello
See ya


This is because object is of Sub type even when it is casted as Base type and sub class has overrideden the methods.
But will cause a warning while compilation as static method is being called as non static element.


4.What distinguishes RuntimeException from other subclasses of Exception?

Runtime exceptions:
�A method signature does not need to declare runtime exceptions
�A caller to a method that throws a runtime exception is not forced to catch the runtime exception
�Runtime exceptions extend from RuntimeException or Error
Other sub class of Exceptions:
�A method must declare each checked exception it throws
�A caller to a method that throws a checked exception must either catch the exception or throw the exception itself
�Checked exceptions extend from Exception
And we should always catch a checked exception once you reach a point where our code can make a meaningful attempt at recovery. However, it is best not to catch runtime exceptions. Instead, we should allow runtime exceptions to bubble up to where we can see them.

5.Simplify the following method

public static int jabberwock(boolean frumious, boolean manxome,
boolean uffish){
if (!frumious){
if (manxome) {
if (uffish){
return JUBJUB_BIRD;
}
else if (!manxome) {
return BANDERSNATCH;
}
else{
return JUBJUB_BIRD;
}
}
else {
return JUBJUB_BIRD;
}
}
else if (!uffish){
if (!manxome){
return BANDERSNATCH;
}
}
else if(!manxome){
return JUBJUB_BIRD;
}
if (!(uffish || !manxome)) {
return BANDERSNATCH;
}
return JUBJUB_BIRD;
}





public static int jabberwock(boolean frumious, boolean manxome,
boolean uffish){
if (!frumious){
if (manxome) {
if (uffish){
return JUBJUB_BIRD;
}

else{
return JUBJUB_BIRD;
}
}
else {
return JUBJUB_BIRD;
}
}
else if (!uffish){
if (!manxome){
return BANDERSNATCH;
}
}
else if(!manxome){
return JUBJUB_BIRD;
}

return JUBJUB_BIRD;
}



6.The following code is a complete application, which accesses a **shared** SQL database. This code seemed ok in test but causes some unrelated updates of salary to be occasionally lost in production. Why could this happen? What options are there to resolve this problem? Hint: Focus on coreLogic.

import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;


public class Operation {
private Connection c;

private void coreLogic(long empId) throws SQLException {
BigDecimal salary = selectSalary(empId);
salary = indexSalary(salary);
updateSalary(empId, salary);
}

public void execute(Connection aConn, long empId)
throws SQLException {
c = aConn;
c.setAutoCommit(false);
try {
coreLogic(empId);
c.commit();
} catch (SQLException e) {
c.rollback();
throw e;
}
}

private BigDecimal selectSalary(long empId) throws SQLException {
PreparedStatement ps = c.prepareStatement(
"SELECT salary FROM emp WHERE emp_id = ?");
ResultSet rs = null;
try {
ps.setLong(1, empId);
rs = ps.executeQuery();
rs.next();
return rs.getBigDecimal("salary");
} finally {
if (rs != null) {
rs.close();
}
ps.close();
}
}

private BigDecimal indexSalary(BigDecimal salary) {
return salary.multiply(new BigDecimal("1.1"));
}

private void updateSalary(long empId, BigDecimal salary)
throws SQLException {
PreparedStatement ps = c.prepareStatement(
"UPDATE emp SET salary = ? WHERE emp_id = ?");
try {
ps.setBigDecimal(1, salary);
ps.setLong(2, empId);
ps.executeUpdate();
} finally {
ps.close();
}
}

public static void main(String args[]) throws Exception {
Class.forName(args[0]);
Connection c = DriverManager.getConnection(args[1], args[2], args[3]);

Operation op = new Operation();
op.execute(c, Long.parseLong(args[4]));
}
}

Sample DDL is for emp is:

CREATE TABLE emp ( emp_id NUMERIC PRIMARY KEY,
salary NUMERIC NOT NULL);
14 years ago