Monday 25 June 2018

TCS ILP experience 2018

Here I am coming up with new stuff for the freshers who are going to join in TCS ILP.
Tcs ILP(click)

I am asking people to share their ILP -Experience who are already joined in tcs. So that next batch can know about ILP. Please spread this sheet to everyone and help them each other. share this link to FACEBOOK TCS groups then their people can write their experience.

Note: Keep watch this page. Once repsoponse comes I will update their expereince here.

Here is the link start fiiling it up.



Sunday 24 June 2018

TCS Tech Lounge JAVA Final-18

An Input device which can read characters directly from an ordinary piece of paper is
Ans: OCR

parseInt() and parseLong() method throws__ ___  _ _ _ ?
Ans: NumberFormatException

To explicitly throw an exception, _ _ _ _ keyword is used.
Ans: throw

How many parameters does the skipByte() accept in DataInputStream class?
Ans: 1

Is the skipByte() of DataInputStream final
Ans: false

Public class Exam1{
Private int a;
Public static void main(Strings[]arg){
/* complete the code using the options so that O is printed in console*/
}           }
ANS: System.out.println(new Exam1().a);
class AccountHolder{
            public AccountHolder(int count){
                       
            }
}
class Account{
            Account(){
                       
            }
}
class Demo{
            public static void main(String[]args){
                        AccountHolder accountholder;
                        accountholder = new AccountHolder();
                        Account accountOne = new Account();
                        Account accountTwo = new Account();
                        Account accountThree = accountTwo;
                        accountThree = accountOne;            
            }
}           while executing the above code, how many reference variable and objects will be crrated
Ans: 3 Objects and 4 references

InputStream class has one constructor.
Ans: True

Java has the characteristic
Ans: All of the above( Portable, Robust, Architecture neutral)

A deployment descriptor describes
Ans: web component settings

What data type does readLine() return?
Ans: String

Which among the following is wrong?
Ans: abstract class can have only static final(constant) variable i.e, by default

What is the result of x when the following loop exists?
Int x=0;
For(in i=0;i<10;i++){
if(i==5){
Continue; }
X++;
}
Ans: 9

String s =”kolkatta”.replace(‘k’,’a’) ?
What would the string “s” would contain after successful execution of the above statement?
Ans: aolaata

The below query returns the students whose age is between 20 to 24 including 20 and 24 also. Select * from Student where Age BETWEEN 20 AND 24
Ans: TRUE

Which life cycle method is called only once in the serbvlet life cycle
Ans: init()

TCS Tech Lounge JAVA Final-17

If the client has disabled cookie in the browser, which session management mechanism could the web container employ?
ANS: Session Management using URL Rewriting

class Super{
            void show(){
                        System.out.println("parent");
            }
}
public class Sub extends Super{
            void show()throws IOException{
                        System.out.println("Child");
            }
            public static void main(String[]args){
                        Super s = new Sub();
                        s.show();
            }
}
ANS: compile error

StringBuffer Objects are mutable objects?
ANS: True


public class Operators1{
            public static void main(String[]args){
                        double x=6;
                        int y=5,z=2;
                        x=y++ + ++x/z;
                        System.out.println(x);
            }
}
ANS: 8.5

Automatically when the view is dropped.
E. The OR REPLACE option is used to change the definition of an existing view without dropping and recreating it.
F. The WITH CHECK OPTION constraint can be used in a view definition to restrict the columns displayed through the view.

Which of the following must be true of the object thrown by a thrown statement?
ANSIt must be assignable to the Throwable type

What will this code print?
Int arr[] = new int[5];
System.out.print(arr);
ANS: Garbage Value

What does read(char[] cbuf, int off, int len) of InputStreamreader do?
ANS: Reads characters into a portion of an array

The default initial values of the data members in Employee class for string name and int id are
ANS: null, 0

Which class handle any type of request so it is protocol-independent?
ANS: GenericServlet

Java is a_ _ __ independent language.
Ans: Platform

 What is the return type of skipByte() func in DataInputStream class?
ANS: int

Aceess modifier can beused for local variables
Ans: false


Which of the following languages is more suited to a structured program?
Ans: Pascal

What is the limit of data to be passed from HTML when doGet() method is used?
ANS: 2k

Switch(x){
Default: System.out.println(“Hello”);
}
Which two are acceptable types of for x?
1.      byte
2.      long
3.      char
4.      float
5.      Short
6.      Long
ANS: 1 and 3

For a 2 tier architecture
1.      Presentation layer in one machine and Business & Resource layer is available in different machine.
2.      Presentation & Business layer in one machine and Resource layer in another machine. Which of the below statements Is true.
ANS: Both statements are true

TCS Tech Lounge JAVA Final-16


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?


ANS: one

TCS Tech Lounge JAVA Final-16

The webserver that executes the servlet creates an _ _ _ _ and passes this to servlets service method(which inturn passes to doget and dopost)
ANS: HttpServlet


public class Sample
{
                                public static void main(String[] args){
                                int[] myArray = new int[3];
                                for(int x:myArray)
                                {
                                    System.out.print(x);
                                }
                                }
}

Ans: 000


Java platform consists of below components.
ANS: Java API, JVM


An InputStreamReader is a bridge from byte streams to ……………………streams.
ANS: Character


What can be appended to Writer class using append() ?
ANS: Character

When you create a FileOutputStream you can decide if you want to overwrite any existing file with the same name, or if you want to append to any existing file.
ANS: True

Reader class is a final class ?
ANS: False

What command is used to compile a Java program eg. Test.java
ANS: javac Test.java

Which method of Writer class is not implemented by subclass ?
ANS: read()

What value does readLine() return upon encountering end-of-file ?
ANS:  null

Can a stream act as a data source for another stream?
ANS:  Yes. Some streams can be connected together.

What is a stream that transforms data in some way called ?
ANS: Processing stream

SELECT * FROM Table1 HAVING Column1 > 10
ANS: The result will be all rows from Table 1 which have Column1 values greater than 10.

Which of the following invokes function in SQL
ANS: Callable statements

The equals method only takes Java objects as an argument , and not primitives, passing primitives will result in a compile time error.
ANS: True

Which of these keywords is not a part of Java exception handling ?
ANS: thrown

A floppy disk contains
ANS: Both circular tracks and sector


public class StringComp{
                       public static void main(String[] args){
                      
                       String s1= "rahul";
                       String s2= "rahul";
                       String s3= new String("459029");
                       String s4= new String("459029");
                       System.out.print(s1.equals(s2));
                       System.out.print((s1==s2));
                       System.out.print(s3.equals(s4));
                       System.out.print((s3==s4));
                      
                      
                       }
}
ANS: true true true false


In BufferedReader what method is used to notify the operating system that a file is no longer needed ?
ANS: close()

In Servlet Terminology what provides rentime environment for JavaEE(j2ee) applications. It performs many operations that are given below: 1. Life Cycle Management 2.Multithreaded support 3. Object Pooling 4.Security etc
ANS: Container

The DTD defines the structure of XML documents
ANS: True

Choose the incorrect one among the following choices:


ANS: List<int> I = new ArrayList<int>();

TCS Tech Lounge JAVA Final-15

To execute a stored procedure <??totalStock>?? in a database server, which of the following code snippet is used?
ANS: CallableStatement clbstmnt = con.prepareCall("{call totalStock}"); cs.executeQuery();

What class is extended by DataOutputStream class?
ANS: FilterOutputStream

Which of these class is used to read and write bytes in a file
ANS: FileInputStream

Evaluate the following command:
CREATE TABLE employees(employee_id NUMBER(2) PRIMARY KEY, last_name VARCHAR2(25) NOT NULL, department_id NUMBER(2), job_id VARCHAR2(8), salary NUMBER(10,2));

You issue the following command to create a view that displays the last names of the sales staff in the organization:
CREATE OR REPLACE VIEW sales_staff_vu AS SELECT employee_id, last_name,job_id FROM employees WHERE job_id LIKE ‘SA_%’ WITH CHECK OPTION;
Which two statements are true regarding the above view? (Choose two.)
A. It allows you to insert rows into the EMPLOYEES table .
B. It allows you to delete details of the existing sales staff from the EMPLOYEES table.
C. It allows you to update job IDs of the existing sales staff to any other job ID in the EMPLOYEES table.
D. It allows you to insert IDs, last names, and job IDs of the sales staff from the view if it is used in multitable INSERT statements.
ANS: B,D
What type of exception can all the function of DataInputStream throws?
ANS: IOException
BufferedWriter class Extends_ _ _ _
ANS: Writer

Why we use array as a parameter of main method
ANS: both of the above( for taking input to the main method, can store multiple values)

public class Exam1{
                                public static void main(String[] args){
                                for(int j=0;j<3;j++){
                                    for(int i=0;i<3;i++){
                                                if(i<2){
                                                            break;
                                                }
                                    }
                                    System.out.println("i="+i);
                                    System.out.println("j="+j);
                                }
                                }
}
ANS: Compile time error

Which of these keywords is used to refer to member of base class from a sub class?
ANS: super

Which of these method of String class is used to obtain character at specified index?
ANS: charAt()

In BufferedOutputStream, the method wait is inherited from:
ANS: java.lang.Object


Close() method closes this input stream and releases any system resources associated with the stream
ANS: YES

The _  _ _ _ method sets the query parameters of the PreparedStatement Object.
ANS: setString()

Which command deletes all information about relation from the database?
ANS: drop table

Java.io.FileInputStream extends from which class?
ANS: java.io.InputStream

Which servlet interface contain life cycle methods
ANS: Servlet

Find the SQL statement below that is equal to the following:
SELECT NAME FROM CUSTOMER WHERE STATE =’VA’;
ANSSELECT NAME FROM CUSTOMER WHERE STATE IN ('VA');
What interface is implemented by DataOutputStream class?
ANS: DataOutput

class output{
                                public static void main(String[] args){
                                String a = "hello i love java";
                                System.out.println(a.indexOf('i')+" "+a.indexOf('o')+" "+a.lastIndexOf('i')+" "+a.lastIndexOf('o'));
                                }
}


ANS: 6 4 6 9

TCS Tech Lounge JAVA Final-14

public class precedence{
                                public static void main(String[] args){
                                    int i = 0;
                                    i= i++;
                                    i= i++;
                                    i= i++;
                                    i= i++;
                                    System.out.println("The value of is"+i);
                                    int arr[] = new int[5];
                                    int index = 0;
                                    arr[index] = index = 3;
                                    System.out.println("The value of first element is"+arr[0]);
                                    System.out.println("The value of fourth element is"+ arr[3]);
                                }
}
ANS: all of the above
The value of i is 0
The value of first element is 3
The value of fourth element is 0

Which of the following has child class?
ANS: FilterReader

Which of these operator is used to allocate memory to array variable in java
ANS: new

What are the key elements of Problem Solving?
ANS:  ALL of these ( declarative & Imperative Knowledge, Good analytical Skills)

public class Exam1{
                                public static void main(String[] args){
                                    int a=5;
                                    int b=2;
                                    int c=a-b;
                                    if(c=3){
                                                System.out.println("Thats correct");
                                    }else{
                                                System.out.println("thats worng");
                                    }
                                }
}
ANS: Compile error

JRE stands for java _ _ _Environment
ANS: Runtime

Which statement is true?
1.      Serialization applies only to OBJECTS
2.      Static variables are NEVER saved as part of the objet state.So static variables are not Serializable.
ANS: Both statements 1&2

Issuing commit command does which of the following
ANS: Release all savepoints

Which of the following is the weakest relationship
ANS: Dependecy

Which of these contain heterogenous objects
ANS: ArrayList

How many parameter does readBoolean() of DataInputStream accepts?
Ans: 0

Which is not method of InputStreamReader
ANS: open()

For a static field, regardless of the number instances created, will hold the same data across all objects
ANS: TRUE

Single line comment starts with _ _ _ in java
ANS: //

What is the name of the stream that connects two running programs?
ANS: Pipe

Hotspot is an implementation of the JVM concept.It provides
ANS: garbage collector


Which method returns the time when the session was created?
ANS: getCreateTime()

public class precedence{
                                public static void main(String[] args){
                                int num = 10;
                                switch(num){
                                    case 8: System.out.println("The selection is 9");
                                    break;
                                    case 20: System.out.println("The selection is 20");
                                    break;
                                    case 30: System.out.println("The selection is 30");
                                    break;
                                    case 40: System.out.println("The selection is 40");
                                    break;
                                    default: System.out.println("Invalid Selection");
                                }
                                }
}


ANS: Invalid selection