Languages [3i Infotech Placement]: Sample Questions 238 - 240 of 546

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

Question 238

Languages
Edit

Describe in Detail

Essay▾

What is an interface?

Explanation

The Abstract Class Implements the Interface
  • An interface is a reference type in java- a collection of abstract methods.
  • An interface without definitions for all functions specifies the set of methods that the inheriting class has to implement.
  • Interface achieves abstraction and multiple inheritance in java representing a IS-A relationship.

Syntax:

  1. Interface <interface_name>
  2. {
  3.     // declare constant fields
  4.     // declare methods that abstract
  5.     // by default.
  6. }

Question 239

Edit

Write in Short

Short Answer▾

What is the output of the following program?

  1. main ()
  2. {
  3.     charp[ ] =“%d”;
  4.     p[1] =‘c’;
  5.     printf (p, 65);
  6. }

Explanation

In the program

Table Shows the Program
p [1] = ‘c’ ;
  • Due to the assignment p [1] = ‘c’ the string becomes, “% c” .
printf (p, 65) ;
  • Since this string becomes the format string for printf and ASCII value of 65 is ‘A’ , the same gets printed.

Question 240

Edit

Write in Short

Short Answer▾

What is the output of the following program?

  1. main ()
  2. {
  3.     char ⚹p;
  4.     p =“%d”;
  5.     p ++;
  6.     p ++;
  7.     printf (p − 2, 300);
  8. }

Explanation

In the program

Table Shows the Program
char ⚹ p;Declare character pointer p
p = “% d” ;Pointer p points to ‘% d’
p ++ ;

p ++ ;

It is incremented twice
printf (p − 2,300) ;Decremented by 2, it points to ‘% d’ and 300 is printed.

Developed by: