Code Purpose
Quiz by , created more than 1 year ago

OOP Quiz on Тест 6, created by Code Purpose on 02/05/2020.

372
0
0
Code Purpose
Created by Code Purpose about 4 years ago
Close

Тест 6

Question 1 of 10

1

Што ќе испечати по извршување на следниот програмски код:

enum counts { n1, n2=2, n3, n4=7, n5, n6 };
int main(){
counts c = n1;
cout << c << “ “;
c = n2; cout << c << “ “; c = n3; cout << c << “ “;
c = n4; cout << c << “ “; c = n5; cout << c << “ “;
c = n6; cout << c << “ “; return 0;
}

Select one of the following:

  • 0 1 2 3 4 5

  • 1 2 3 7 8 9

  • 0 2 3 7 8 9

  • 0 2 0 7 0 0

Explanation

Question 2 of 10

1

Што треба да се вклучи во С++ програма за да се овозможи употреба на стандардните влезо-излезни текови?

Select one of the following:

  • #include <stdio.h>

  • #include <fstream>

  • #include <iostream>

  • #include <stdio>

Explanation

Question 3 of 10

1

Дадени се функциите:

int f (int x) { return x/4; }
float f(float x) { return x/4; }

Што ќе се ипечати по извршување на наредбите:
double x=8.4; cout << f(x);

Select one of the following:

  • 2.1

  • 2

  • 0

  • ќе има грешка при преведување на програмата

Explanation

Question 4 of 10

1

На колку различни начини може да се повика функцијата:

int Volume(int x=0, int y = 0, int z =3) { return x*y*z;}

Select one of the following:

  • 1

  • 0

  • 3

  • 4

Explanation

Question 5 of 10

1

Ако меморијата била ослободена со кодот delete[] niza, како била резервиранаа:

Select one of the following:

  • int* niza = new int

  • char* niza = new char[10]

  • int niza = new int[10]

  • charniza[10]

Explanation

Question 6 of 10

1

Кој е валиден прототип за operator >> на класата Krug:
class Krug { private: int a, b, c; public: … }

Select one of the following:

  • friend operator &istream>>(istream &input, const Krug &k)

  • friend operator &istream>>(istream &input, Krug &k)

  • operator &istream>>(istream &input, const Krug &k)

  • operator &istream>>(istream &input, Krug &k)

Explanation

Question 7 of 10

1

Дефинирана е класата:
class A {
double i;
public: A(double ii = 0.0) {}
const A operator - (const A & a1) {
return A(i - a1.i);
}
friend
const A operator + (const A & a1,
const A & a2) {
return A(a1.i + a2.i);
}
};
int main() {
A a(2.3), b(3.5), c;

return 0;
}
Која од следните наредби не е валидна?

Select one of the following:

  • c = a + 8.2;

  • c = 3.4 – b;

  • c = b – 4.6;

  • c = 7.6 + a;

Explanation

Question 8 of 10

1

Како се пристапува до името (name) на првиот елемент на полето emp во структурата comp:

struct Employee { char name[100]; };
struct Company ( Employee emp[50]; } comp;

Select one of the following:

  • comp.emp[0].name;

  • comp->emp[0]->name;

  • Company :: emp[0].name;

  • comp.emp.name[0];

Explanation

Question 9 of 10

1

Даден е следниот програмски код:
typedef struct oopStruktura
{ int i; } oopStr;
typedef oopStr *pok; oopStr prom; pok prom_pok = &prom;
Која од следните наредби е валидна?

Select one of the following:

  • prom_pok.i = 10;

  • prom_pok->i = 10;

  • oopStr->i = 10;

  • prom->i = 10;

Explanation

Question 10 of 10

1

Нека е дадена класа за репрезентација на правоаголник. Која од следните наредби за креирање објект е грешка:

class p{
int c, d;
public:
P(int c, int d =6) {
this->c = c;
this->d = d;
}
};

Select one of the following:

  • P c();

  • P *c = new P (3);

  • P c(3);

  • P c(1, 2);

Explanation