Тест 6

Description

OOP Quiz on Тест 6, created by Code Purpose on 02/05/2020.
Code Purpose
Quiz by Code Purpose, updated more than 1 year ago
Code Purpose
Created by Code Purpose almost 4 years ago
372
0

Resource summary

Question 1

Question
Што ќе испечати по извршување на следниот програмски код: 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; }
Answer
  • 0 1 2 3 4 5
  • 1 2 3 7 8 9
  • 0 2 3 7 8 9
  • 0 2 0 7 0 0

Question 2

Question
Што треба да се вклучи во С++ програма за да се овозможи употреба на стандардните влезо-излезни текови?
Answer
  • #include <stdio.h>
  • #include <fstream>
  • #include <iostream>
  • #include <stdio>

Question 3

Question
Дадени се функциите: int f (int x) { return x/4; } float f(float x) { return x/4; } Што ќе се ипечати по извршување на наредбите: double x=8.4; cout << f(x);
Answer
  • 2.1
  • 2
  • 0
  • ќе има грешка при преведување на програмата

Question 4

Question
На колку различни начини може да се повика функцијата: int Volume(int x=0, int y = 0, int z =3) { return x*y*z;}
Answer
  • 1
  • 0
  • 3
  • 4

Question 5

Question
Ако меморијата била ослободена со кодот delete[] niza, како била резервиранаа:
Answer
  • int* niza = new int
  • char* niza = new char[10]
  • int niza = new int[10]
  • charniza[10]

Question 6

Question
Кој е валиден прототип за operator >> на класата Krug: class Krug { private: int a, b, c; public: … }
Answer
  • 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)

Question 7

Question
Дефинирана е класата: 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; } Која од следните наредби не е валидна?
Answer
  • c = a + 8.2;
  • c = 3.4 – b;
  • c = b – 4.6;
  • c = 7.6 + a;

Question 8

Question
Како се пристапува до името (name) на првиот елемент на полето emp во структурата comp: struct Employee { char name[100]; }; struct Company ( Employee emp[50]; } comp;
Answer
  • comp.emp[0].name;
  • comp->emp[0]->name;
  • Company :: emp[0].name;
  • comp.emp.name[0];

Question 9

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

Question 10

Question
Нека е дадена класа за репрезентација на правоаголник. Која од следните наредби за креирање објект е грешка: class p{ int c, d; public: P(int c, int d =6) { this->c = c; this->d = d; } };
Answer
  • P c();
  • P *c = new P (3);
  • P c(3);
  • P c(1, 2);
Show full summary Hide full summary

Similar

Object Oriented Programming Concepts
Cmagapu
Concepts of Objects and Classes
BK Modding
Introduction to Java
BK Modding
Paradigma de Programación Orientado a Objetos
JULIAN CAMILO RIVEROS FONSECA
1.2.4 OOP
Louis N
constructor
balakvm.it
Classes
needajob517
OOP Definitions
Matt Dumbrill
Object Oriented Programming Concepts
agni bharathi
Object Oriented Programming Concepts
Rian McCollom