Select the equivalent answers for the code given below ?
Boolean b=true;
If(b){
x=y;
}else
{ x=z;}
ANS: x=b ? x=y : x=z;
Which one of the following will declare an array and initialize it with five numbers
ANS: int [] a={23,22,21,20,19};
Which statement about HttpSession is not true ?
ANS: A session will become invalid as soon as the user close all the browser window
What are the methods declared by the Iterators
ANS: All of the above [ Boolean hasNext(), Object next(), void remove();
…………….. are the list of arguments that come into function.
ANS: Parameters
public class Test{
public static void main(String[] args){
display(null);
}
private static void display(String str)
{
if(str==null)
throw new NullPointerException();
else
System.out.println("String is :"+str); }
}
ANS: Null Pointer exception will occur if the program is run.
CREATE TABLE product
(pcode NUMBER(2),
pnameVARCHAR2(10));
INSERT INTO product VALUES(1, 'pen');
INSERT INTO product VALUES (2,'penci');
SAVEPOINT a;
UPDATE product SET pcode = 10 WHERE pcode = 1;
SAVEPOINT b;
DELETE FROM product WHERE pcode = 2;
COMMIT;
DELETE FROM product WHERE pcode=10;
ROLLBACK TO SAVEPOINT a;
ANS: Both the DELETE statements and the UPDATE statement would be rolled back
CREATE TABLE CUSTOMER(customerid NUMBER(3,2),customername VARCHAR2(10));
INSERT INTO CUSTOMER VALUES(1,’a’);
ALTER TABLE CUSTOMER ADD constraint chk_lenght_5 CHECK (length(customername)>5);
ANS: It will add the constraints to check that customername should have minimum 5 characters
The_ _ __ __ _ __ method executes a simple query and returns a single Result Set object.
ANS: executeQuery
How many constructors are there in DataInputStream class?
ANS: 1
public class precedence{
public static void main(String[] args){
StringBuffer stb = new StringBuffer("yadroh");
// line4 //
System.out.println(stb.toString());
}
}
ANS: stb.replace(3,4,”li”).reverse();
You need to create a table for a banking application with the following considerations:
1. You want a column in the table to store the duration of the credit period
2. The data in the column should be stored in a format such that it can be easily added and substracted with
3. Data type data without using the conversation functions
4. The maximum period of the credit provision in the application is 30 days
5. The interest has to be calculated for the number of days an individual has taken a credit for.
Which data type would you use for such a column in the table?
ANS: INTERAL DAY TO SECOND
Which of these method of InputStream is used to read integer representation of next available byte input?
Ans: read()
FileWriting class ___ from the InputStreamWiter class
ANS: inherits
Which method is not present in HttpServlet class
Ans: service
JDK consists of
ANS: all of the above(tools for development, JRE, JVM)
How many copies of a JSP page can be in memory at a time?