Accenture – Company Specific – Programming – Set 4

Test Name: Accenture – Company Specific – Programming – Set 4

Question1:

Write a program to find the largest y-x for an entered list such that a[y] > a[x], where y and x are index position. The output should be displayed the result of largest y-x.



Solution (C++):
No Solution

Tags: KIIT_Baseline, TCS_New

Question2:

What is the output of following java program?

import java.util.*;

class Main
{
    public static void main(String[] args) 
    {
        TreeSet<Integer> t = new TreeSet<Integer>();
        t.add(4);
        t.add(4);
        t.add(3);
        t.add(2);
        t.add(5);
        System.out.println(t);
    }
}



Ans: [2, 3, 4, 5]

Tags: Capgemini1, NEW_Q

Question3:

#include <stdio.h>

int main()

{

int a = 10, b = 20, c = 30;

if (c > b > a)

printf(“TRUE”);

else

printf(“FALSE”);

return 0;

}



Ans: FALSE

Tags:

Question4:

FILE reserved word is



Ans: It is a type name defined in stdio.h

Tags:

Question5:

Which if these can we type in the Run dialogue box to start MS Office.



Ans: winword.exe

Tags:

Question6:

Which method can be used to check file Accessiblity?



Ans: is Readable(path), is Writable(path), and is Executable(path)

Tags: java

Question7:

How do you initialize an array in C?



Ans: int arr[4] = {1,2,3,4};

Tags: TATA_Elxsi, IN03

Question8:

What does bind() method of ServerSocket offer?



Ans: binds the serversocket to a specific address (IP address and port)

Tags: java

Question9:

Which statement is correct about the following declaration in C/C++?

int *ptr, p;



Ans: ptr is a pointer to integer, p is not

Tags: c++

Question10:

Which class provides system independent server side implementation in java?



Ans: ServerSocket

Tags: java

Question11:

Which of these terms is used to denote a letter and number in the intersecting column and row :



Ans: Cell coordinates

Tags:

Question12:

In java, hasNext() method of an iterator returns which type of value?



Ans: Boolean

Tags: java

Question13:

What is the output of this C code?

#include <stdio.h>

void main()

{

int i = 0;

if (i == 0)

{

printf(“Myperfectice”);

break;

}

}



Ans: Compile time error

Tags:

Question14:

Which statement is correct about the following declaration in C/C++?

const int *ptr;



Ans: You cannot change the value pointed by ptr

Tags: c++

Question15:

Switch statement accepts.



Ans: all of the mentioned

Tags:

Question16:

1.     What will be the output of the program?

class Bool

{

public static void main(String [] args)

{

boolean a11 = true;

boolean a21 = false;

boolean a31 = true;

if ( a11 & a21 | a21 & a31 | a21 ) /* Line 8 */

System.out.print(“ok “);

if ( a11 & a21 | a21 & a31 | a21 | a11 ) /*Line 10*/

System.out.println(“dokey”);

}

}



Ans: do key

Tags: java

Question17:

If we execute the following 2 statements in C++, then what type of variables are p and q?
typedef char* CHAR;
CHAR p,q



Ans: char*

Tags: c++

Question18:

Which of these methods is used to compare a specific region inside a string with another specific region in another string in java?



Ans: regionMatches()

Tags: java

Question19:

Which of the following classes in java is used to implement a dynamic array?



Ans: ArrayList

Tags: L&T_InfoTech1, NEW_Q, Other_TY_Baseline, IN05

Question20:

You are given a chess board of (n x n) and a knight piece. You have to visit all the chess places/boxes in the chess but there is one constraint “you can not visit the same place/box again”. (one place/box in chess will only be visited only once). You have to find all the possible paths so that the knight can visit al the places/boxes in chess without visiting the same place/box again. You can start from any place/box in the chess.



Solution (C++):
No Solution

Tags: Backtracking

Question21:

What is the output of this C code(When 1 is entered)?

#include <stdio.h>

void main()

{

int ch;

printf(“enter a value btw 1 to 2:”);

scanf(“%d”, &ch);

switch (ch)

{

case 1:

printf(“1\n”);

default:

printf(“2\n”);

}

}



Ans: 1 2

Tags:

Question22:

Which of these operators is used to allocate memory to array variable in Java?

 



Ans: new

 

Tags: Java, NEW_Q, Other_TY_Baseline

Question23:

What is the output of this C code?

#include <stdio.h>

int main()

{

char *p = NULL;

char *q = 0;

if (p)

printf(” p “);

else

printf(“nullp”);

if (q)

printf(“q\n”);

else

printf(” nullq\n”);

}



Ans: nullp nullq

Tags: c++

Question24:

What is the output of this java program?

class Abc

{

    public static void main(String[]args)

    {

        String[] elements = { “for”, “tea”, “too” };

        String first = (elements.length > 0) ? elements[0]: null;

    }

}



Ans: No output and the variable first is set to elements[0].

Tags: java

Question25:

Choose a shortcut to open dialogue box :



Ans: Ctrl + F12

Tags:

Question26:

Which of these methods is used to get the present size of an ArrayList object?



Ans: size()

Tags: Capgemini1, NEW_Q

Question27:

In CGI, process starts with each request and will initiate OS level process.



Ans: True

Tags: java

Question28:

Which operator is used to insert the data into file?



Ans: << 

Tags: c++

Question29:

Below some C++ statements are given. Which of the statements is wrong?

int var = 10;
int *ptr = &(var + 1); //statement 1
int *ptr2 = &var; //statement 2
&var = 40; //statement 3



Ans: Statement 1 and 3 are wrong

Tags: c++

Question30:

Which among following is used to open a file in binary mode ?



Ans: ios::binary

Tags: c++

Question31:

Which among following is correct syntax of closing a file in c++?



Ans: myfile.close();

Tags: c++

Question32:

Which method of vector class in java is used to reduce its capacity? 



Ans: trimToSize()

Tags: Sapient, NEW_Q

Question33:

What is the output of the following C code?

#include<stdio.h>

int main()
{
    int a = 1;
    int *b = &a;
    int **c = &b;
    **c = 2;
    printf(“%d\n”,a);
}
 



Ans: 2

Tags: IBM1, NEW_Q

Question34:

You can relate Microsoft Office to which of these examples?



Ans: horizontal market software

Tags:

Question35:

What will be the output of this java program?

import java.util.*; 
class Main 
{ 
    public static void main(String args[]) 
    { 
        HashMap<Integer, Character> map = new HashMap<>(); 
        map.put(10,'a'); 
        map.put(30,'b'); 
        map.put(20,'c'); 
        map.put(25,'d');
        map.put(15,'e');
        System.out.println(map);
    } 
} 

 



Ans: {20=c, 25=d, 10=a, 30=b, 15=e}

Tags: L&T_InfoTech1, NEW_Q

Question36:

What is the sequence for preprocessor to look for the file within <>?



Ans: The predefined location then the current directory

Tags:

Question37:

Which method is used to increase the capacity of ArrayList object manually?



Ans: ensureCapacity()

Tags: Capgemini1, NEW_Q

Question38:

Which of these is an incorrect statement about strings in java?



Ans: StringBuffer class is used to store string in a buffer for later use

Tags: java

Question39:

Which of the following operations cannot be performed on an array arr in C/C++?

I)  ++arr

II) arr+1

III) arr++

IV) arr*2



Ans: I, III and IV

Tags: c++, Qualcomm_NEAT_PROG, CAT2_MC4, MCA_MC2, IN01

Question40:

When 1 is entered, The output of the code below is?

#include <stdio.h>

void main()

{

int ch;

printf(“enter a value btw 1 to 2:”);

scanf(“%d”, &ch);

switch (ch, ch + 1)

{

case 1:

printf(“1\n”);

break;

case 2:

printf(“2”);

break;

}

}



Ans: 2

Tags:

Question41:

Which of these operators can be used to concatenate two or more String objects in java?



Ans: +

Tags: java

Question42:

Which of the following can be termed as a collection of information saved as unit.



Ans: file

Tags:

Happy Learning – If you require any further information, feel free to contact me.

Share your love
Saurav Hathi

Saurav Hathi

I'm currently studying Bachelor of Computer Science at Lovely Professional University in Punjab.

📌 Nodejs and Android 😎
📌 Java

Articles: 444

Leave a Reply

Your email address will not be published. Required fields are marked *