qamrun nisa


{ City } delhi
< Country > india
* Profession *
User No # 56034
Total Questions Posted # 0
Total Answers Posted # 10

Total Answers Posted for My Questions # 0
Total Views for My Questions # 0

Users Marked my Answers as Correct # 32
Users Marked my Answers as Wrong # 7
Questions / { qamrun nisa }
Questions Answers Category Views Company eMail




Answers / { qamrun nisa }

Question { Process IT, 7544 }

what r the disadvantages of MVC-2 Architecture?


Answer

Can u please tell me why is not reconmmanede for the small
size application??

Is This Answer Correct ?    0 Yes 1 No

Question { Photon, 7028 }

"Sun Certified Java Programmer" This is one String , we need
to print SCJP, write the java code dynamically? pls reply
this questions


Answer

public class Sample {

public static void main(String args[]) {
String str = "Sun Certified Java Programmer";
StringTokenizer st = new StringTokenizer(str, " ");
while (st.hasMoreTokens()) {
String value = st.nextToken();
System.out.print(value.charAt(0));
}
}
}

Is This Answer Correct ?    5 Yes 0 No


Question { Wipro, 8108 }

Explain the following statement: Java is always pass-by-value.


Answer

Other languages use pass-by-reference or pass-by-pointer.
But in Java no matter what type of argument you pass the
corresponding parameter (primitive variable or object
reference) will get a copy of that data, which is exactly
how pass-by-value (i.e. copy-by-value) works.

In Java, if a calling method passes a reference of an object
as an argument to the called method then the passedin
reference gets copied first and then passed to the called
method. Both the original reference that was passed-in and
the copied reference will be pointing to the same object. So
no matter which reference you use, you will be always
modifying the same original object, which is how the
pass-by-reference works as well.

Is This Answer Correct ?    15 Yes 2 No

Question { 6451 }

What is immutable class? how to make a Class explicitly
"Immutable"?Wap to make a class explicitly immutable.


Answer

Immutable objects whose state (i.e. the object’s data) does
not change once it is instantiated (i.e. it becomes a
read-only object after instantiation). Immutable classes are
ideal for representing numbers (e.g. java.lang.Integer,
java.lang.Float, java.lang.BigDecimal etc are immutable
objects), enumerated types, colors (e.g. java.awt.Color is
an immutable object), short lived objects like events,
messages etc.

Writing an immutable class is generally easy but there can
be some tricky situations. Follow the following guidelines:
1. A class is declared final (i.e. final classes cannot be
extended).
public final class MyImmutable { … }
2. All its fields are final (final fields cannot be mutated
once assigned).
private final int[] myArray; //do not declare as -> private
final int[] myArray = null;
3. Do not provide any methods that can change the state of
the immutable object in any way – not just setXXX
methods, but any methods which can change the state.
4. The “this” reference is not allowed to escape during
construction from the immutable class and the immutable
class should have exclusive access to fields that contain
references to mutable objects like arrays, collections
and mutable classes like Date etc by:
• Declaring the mutable references as private.
• Not returning or exposing the mutable references to the
caller (this can be done by defensive copying)

Is This Answer Correct ?    1 Yes 0 No

Question { Oracle, 8380 }

What are the Abstract Classes provided by Java?


Answer

java.io.InputStream
java.io.OutputStream
java.io.Reader
java.io.Writer

Is This Answer Correct ?    1 Yes 1 No

Question { Oracle, 6907 }

Why are inner classes required?


Answer

when an inner class is defined it is a member of the outer
class in much the same way as other members like attributes,
methods and constructors. When we access private data
members of the outer class, the JDK compiler creates
package-access member functions in the outer class for the
inner class to access the private members. This leaves a
security hole.

In general we should avoid using inner classes. Use inner
class only when an inner class is only relevant in the
context of the outer class and/or inner class can be made
private so that only outer class can access it. Inner
classes are used primarily to implement helper classes like
Iterators, Comparators etc which are used in the
context of an outer class.

Is This Answer Correct ?    7 Yes 0 No

Question { 3470 }

what is the context


Answer

This is an interface that represents a naming context, which
consists of a set of name-to-object bindings. It contains
methods for examining and updating these bindings.

Syntax is

public interface Context

Is This Answer Correct ?    0 Yes 0 No

Question { IBM, 5591 }

use of wrapper classes?


Answer

Wrapper classes are used to wrap primitive types (eg: int,
double, etc) in Objects which can be placed into Vectors,
and many, many other uses.

Following table lists the primitive types and the
corresponding wrapper classes:

Primitive Wrapper

Boolean java.lang.Boolean
Byte java.lang.Byte
Char java.lang.Character
double java.lang.Double
Float java.lang.Float
Int java.lang.Integer
Long java.lang.Long
Short java.lang.Short
Void java.lang.Void

Is This Answer Correct ?    1 Yes 3 No

Question { 4950 }

what r callable statement and give their proper use


Answer

CallableStatement is invoked to call stored procedure.
The basic steps are:

1. Invoke the Connection.prepareCall method to create a
CallableStatement object.
2. Invoke the CallableStatement.setXXX methods to pass
values to the input (IN) parameters.
3. Invoke the CallableStatement.registerOutParameter
method to indicate which parameters are output-only (OUT)
parameters, or input and output (INOUT) parameters.
4. Invoke one of the following methods to call the stored
procedure:

CallableStatement.executeUpdate
Invoke this method if the stored procedure does
not return result sets.
CallableStatement.executeQuery
Invoke this method if the stored procedure returns
one result set.
CallableStatement.execute
Invoke this method if the stored procedure returns
multiple result sets.

5. If the stored procedure returns result sets, retrieve
the result sets. See Retrieve multiple result sets from a
stored procedure in a JDBC application.
6. Invoke the CallableStatement.getXXX methods to
retrieve values from the OUT parameters or INOUT parameters.
7. Invoke the CallableStatement.close method to close the
CallableStatement object when you have finished using that
object.

The following code illustrates calling a stored procedure
that has one input parameter, four output parameters, and no
returned ResultSets. The numbers to the right of selected
statements correspond to the previously-described steps.

int ifcaret;
int ifcareas;
int xsbytes;
String errbuff;
Connection con;
CallableStatement cstmt;
ResultSet rs;
...
cstmt = con.prepareCall("CALL DSN8.DSN8ED2(?,?,?,?,?)");
1
// Create a
CallableStatement object
cstmt.setString (1, "DISPLAY THREAD(*)");
2
// Set input parameter
(DB2 command)
cstmt.registerOutParameter (2, Types.INTEGER);
3
// Register output parameters
cstmt.registerOutParameter (3, Types.INTEGER);
cstmt.registerOutParameter (4, Types.INTEGER);
cstmt.registerOutParameter (5, Types.VARCHAR);
cstmt.executeUpdate(); // Call the stored
procedure 4
ifcaret = cstmt.getInt(2); // Get the output
parameter values 6
ifcareas = cstmt.getInt(3);
xsbytes = cstmt.getInt(4);
errbuff = cstmt.getString(5);
cstmt.close();

Is This Answer Correct ?    0 Yes 0 No

Question { Rolta, 8407 }

What is the use of static import ?


Answer

The static import construct allows unqualified access to
static members without inheriting from the type containing
the static members. Instead, the program imports the
members, either individually:

import static java.lang.Math.PI;

or en masse:

import static java.lang.Math.*;

Once the static members have been imported, they may be used
without qualification:

double r = cos(PI * theta);

The static import declaration is analogous to the normal
import declaration. Where the normal import declaration
imports classes from packages, allowing them to be used
without package qualification, the static import declaration
imports static members from classes, allowing them to be
used without class qualification.

Is This Answer Correct ?    2 Yes 0 No