Languages-C & C Plus Plus [3i Infotech Placement]: Sample Questions 130 - 132 of 354

Glide to success with Doorsteptutor material for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 130

C & C Plus Plus
Edit

Describe in Detail

Essay▾

What is an object?

Explanation

Understanding of Object, Its Properties and Its Methods
  • Object is created from a class.
  • Objects of a class are declared in same way as variables of basic types.
  • When a class is defined, no memory is allocated but when it is instantiated memory is allocated.

Declaring object:

  • When a class is defined, only the specification for the object is defined; no memory or storage is allocated.
  • To use the data and functions in the class, we need to create objects.

Syntax:

ClassName ObjectName;

Question 131

C & C Plus Plus
Edit

Write in Short

Short Answer▾

What is the output of the following program?

  1. main ()
  2. {
  3.     intk =1;
  4.     printf(“%d==1is” “%s” k, k == 1? “TRUE” :“FALSE”);
  5. }

Explanation

1 == 1 is TRUE

In a program

Table Shows the Program
int k = 1;Given the integer variable k = 1
printf ( “% d == 1 is” “% s” k, k == 1? “TRUE” : “FALSE” ) ;Two strings are placed together.

They are concatenated (this is called as “stringization operation” ) .

So the string is interpreted as “% d == 1 is % s” .

The conditional operator (? :) evaluates to “TRUE” .

Question 132

C & C Plus Plus
Edit

Write in Short

Short Answer▾

What is the output of the following program?

  1. main ()
  2. {
  3.     inti =5;
  4.     printf (“%d”, i =+ +i == 6);
  5. }

Explanation

In the program

Table Shows the Program
int i = 5;
  • Given the integer variable i = 5
printf ( “% d” , i =+ + i == 6) ;
  • The expression can be treated as i = (++ i == 6) , because == is of higher precedence than = operator.
  • In the inner expression, ++ i is equal to 6 yielding true (1) .

Developed by: