Please login

Prime

Prepinsta Prime

Video courses for company/skill based Preparation

(Check all courses)
Get Prime Video
Prime

Prepinsta Prime

Purchase mock tests for company/skill building

(Check all mocks)
Get Prime mock

HackerRank String Manipulation Quiz-3

Question 1

Time: 00:00:00
What is the output of the following C program?

 

     int arr[8] = {10,12,24,[7]=27,18,90};

compiler error

compiler error

 runtime error

 runtime error

not possible in C

not possible in C

none

none

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 2

Time: 00:00:00
public class PrepInsta
{
Integer a;
int x;
public PrepInsta (int b)
{
x = a + b;
System.out.println (x);
}
public static void main (String[]args)
{
new PrepInsta (new Integer (8));
}
}

What will be the output of this code?

Compilation fails because of an error in line

Compilation fails because of an error in line

The value “4” is printed at the command line

The value “4” is printed at the command line

 A NullPointerException occurs at runtime

 A NullPointerException occurs at runtime

An IllegalStateException occurs at runtime

An IllegalStateException occurs at runtime

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 3

Time: 00:00:00
Which of the following Encodes this String into a sequence of bytes?

byte getBytes()

byte getBytes()

 boolean getBytes()

 boolean getBytes()

byte getValueOf()

byte getValueOf()

 boolean getValueOf()

 boolean getValueOf()

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 4

Time: 00:00:00
An element of a C string is always stored in?

 random memorial allocation

 random memorial allocation

sequential memorial allocation

sequential memorial allocation

exponential memorial allocation

exponential memorial allocation

none

none

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 5

Time: 00:00:00
int main()
{
char alpha = 'p';
printf("%d ", sizeof("q"));
printf("%d ", sizeof('p'));
printf("%d ", sizeof(10));
printf("%d ", sizeof(alpha));
}

What is the output?

2222

2222

2221

2221

1111

1111

 2112

 2112

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 6

Time: 00:00:00
#include<stdio.h>

#include<stdlib.h>

int main()

{

    char str[4]="PrepSters";

    printf("%s",str);

}

What is the output of  the following C program with strings ?

PrepGarbageValue

PrepGarbageValue

Compiler error

Compiler error

prep

prep

PrepSters

PrepSters

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 7

Time: 00:00:00
#include<stdio.h>
#include<stdlib.h>
int main()
{
char str1[]="PrepInsta";
char str2[20];
str2= str1;
printf("%s",str2);
return 0;
}


What is the output of  the following C program with strings ?

Compiler error

Compiler error

PrepInsta

PrepInsta

Garbage value

Garbage value

 none

 none

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 8

Time: 00:00:00
  

   class PrepInsta

{

       public static void main(String args[])

       {

           char c[]={'a', '1', 'b' ,' ' ,'A' , '0'};

           for (int i = 0; i < 5; ++i)

           {

                  if(Character.isDigit(c[i]))

                      System.out.println(c[i]+" is a digit");

                  if(Character.isWhitespace(c[i]))

                      System.out.println(c[i]+" is a Whitespace character");

                  if(Character.isUpperCase(c[i]))

                      System.out.println(c[i]+" is an Upper case Letter");

                  if(Character.isLowerCase(c[i]))

                      System.out.println(c[i]+" is a lower case Letter");

              i=i+3;

           }

       }

   }

What will be the output of the following Java code?

a is a lower case Letter A is an uppercase Letter

a is a lower case Letter A is an uppercase Letter

a is a lower case Letter is White space character

a is a lower case Letter is White space character

a is a lower case Letter 0 is a digit

a is a lower case Letter 0 is a digit

b is a lower case Letter is White space character

b is a lower case Letter is White space character

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 9

Time: 00:00:00
int main()

{

    char str1[]="PREP,";

    char str2[15]="INSTA ";

    strcat(str2,str1);

    printf("%s",str2);

    printf("%s",str1);

}


 What is the output of the C program ?
 

PREP PREP

PREP PREP

PREP INSTA

PREP INSTA

INSTA PREP , PREP 

INSTA PREP , PREP 

none

none

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

Question 10

Time: 00:00:00
int main()

{

    char *prep[2];

    prep[0]= (char *)malloc(4);

    strcpy(prep[0], "STER");

    printf("%s", prep[0]);

    return 0;

}


 What will be the output of a C program with an array of pointers to strings?
 

Prep

Prep

STER

STER

PrepSTER

PrepSTER

none

none

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Start

["0","40","60","80","100"]
["Need more practice!","Keep trying!","Not bad!","Good work!","Perfect!"]