TCS Technical MCQs - 26 October 2020 - Slot 2


Questions 41: float (*p)[5];

Here, p is ____________________________________

  • Options
  • a : pointer
  • b : array of pointer
  • c : float
  • d : pointer to array of float
  • Answer: d) pointer to array of float

    Questions 42: What will be the output of the following program?

    import java.util.*;
    public class Main{
    public static void main(String args[])
    {
    ArrayList < Integer > TempArrayList=new ArrayList< Integer >();
    TempArrayList.add(30);
    TempArrayList.add(20);
    TempArrayList.add(10);
    TempArrayList.add(40);
    TempArrayList.add(50);
    Collections.sort(TempArrayList,Collections.reverseOrder());
    Collections.sort(TempArrayList,Collections.reverseOrder());
    System.out.println(TempArrayList);
    }
    }


    Type your answer in the box below:

    Answer: 50, 40, 30, 20, 10

    Questions 43: What is the function rewind()?

  • Options
  • a : Setting file pointer at the end of file.
  • b : Setting file pointer anywhere in file.
  • c : Setting file pointer at the beginning of file.
  • d : Setting file pointer at the end of line
  • Answer: c) Setting file pointer at the beginning of file.

    Questions 44: Consider following variables declarations

    float num1;
    short num2;
    Long num3;

    What is the datatype of num1 - num3 / num2 ?

  • Options
  • a : double
  • b : short
  • c : float
  • d : None of the given options
  • Answer: c) float

    Questions 45: What will be the output of the following program:

    abstract class Shape
    {
    public abstract void Disp();
    }

    class Triangle extends Shape
    {
    public final void Disp(){
    System.out.println("Triangle");
    }
    }

    class Rectangle extends Triangle
    {
    public void Disp(){
    System.out.println("Its Rectangle");
    }
    }

    public class Main{
    public static void main(String args[])
    {
    Rectangle obj=new Rectangle();
    obj.Disp();
    }
    }

  • Options
  • a : Its Rectangle
  • b : Compile Time error
  • c : Runtime Error
  • d : Triangle
  • Answer: b)Compile Time error

    Questions 46: Construct Post order Traversal for the constructed Tree with the given In- Order and Pre- Order Traversals:

    In - Order : 9 7 10 6 8
    Pre - Order : 6 7 9 10 8

  • Options
  • a : 9 10 7 8 6
  • b : 9 7 6 10 8
  • c : 8 9 10 7 6
  • d : 9 8 10 7 6
  • Answer: a) 9 10 7 8 6

    Questions 47: The kind of software testing you can do when you have both the source code and the executable code in hand?

  • Options
  • a : Blue Box Testing
  • b : White Box Testing
  • c : Red Box Testing
  • d : Black Box Testing
  • Answer: c) Red Box Testing

    Questions 48: Select the precise options for the below scenarios

    Expression 1: cout << endl;
    Expression 2: cout<<'\n'<< flush;

  • Options
  • a : Both expresssion will give same results
  • b : Both expresssion will give different results
  • c : First expression will not insert new line
  • d : Second expression will not insert new line
  • Answer: NA

    Questions 49: Spot the error in the given code. If there is no error, select the most appropriate option

    class Employee
    {
    private :
    int UserId;
    public :
    Employee(): UserId(0){} // ------------- line 8
    friend int displayUser( Employee);
    };

    int displayUser(Employee emp)
    {
    emp.UserId + =12;
    return emp.UserId; // ------------- line 14
    }

    int main()
    {
    Employee e;
    count << "Employee UserId: " << displayUser(e) << endl; // ------------- line 19
    return 0;
    }

  • Options
  • a : Compile Time error
  • b : Runtime Error
  • c : 12
  • d : None of the above
  • Answer: NA

    Questions 50: What will be the output of the below program:

    public class Main
    {
    public static void main(String args[])
    {
    int x=10, y, z;
    z = y = x ;
    y - = x --;
    z - = -- x;
    x - = --x - x-- ;
    System.out.println(x+"-"+y+"-"+z);
    }
    }

    Answer: 8-0-2


    TCS
    If you find any question wrong, please send your solution to [email protected]


    More Questions Will Be Uploaded Soon............