0%
67

1 / 20

Category: (Java)

1. An online shopping application has a Cart class that stores Product objects. How should this relationship be modeled?

2 / 20

Category: (Java)

2. In an ecommerce system, you want to hide sensitive user details like passwords. Which OOP principle helps achieve this?

3 / 20

Category: (Java)

3. Which of the following is not a valid reason to use an interface in Java?

4 / 20

Category: ( C )

4. What is the output of the following code?

#include

int main() {

int x = 10;

if (x == 10)

printf("x is 10\n");

else;

printf("x is not 10\n");

return 0;

}

5 / 20

Category: ( C++ )

5. Which of these is NOT a property of std::shared_ptr?

6 / 20

Category: ( C )

6. What would be output following C program?

#include
int main()
{
int iVal;
char cVal;
// void pointer
void* ptr;
iVal = 50;
cVal = 65;
ptr = &iVal;
printf("value =%d, size= %d\n", *(int*)ptr, sizeof(ptr));
ptr = &cVal;
printf("value =%d, size= %d\n", *(char*)ptr, sizeof(ptr));
return 0;
}

7 / 20

Category: (Java)

7. What will be the output of the following code?
java
class Test {
public static void main(String[] args) {
String s1 = "abc";
String s2 = new String("abc");
System.out.println(s1 == s2);
}
}

8 / 20

Category: ( C )

8. What is the output of the following code?

#include

#define SQUARE(x) x * x

int main() {

printf("%d", SQUARE(3 + 1));

return 0;

}

9 / 20

Category: ( C++ )

9. What is the output of this code?

#include

int main() {

int x = 10;

auto lambda = [&]() { x += 5; };

lambda();

std::cout << x; return 0; }

10 / 20

Category: ( C++ )

10. Which C++ feature does the "Rule of Five" pertain to?

11 / 20

Category: ( C )

11. What is the output of this code?

#include

int main() {

char str[] = "C Programming";

printf("%c", *(str + 3));

return 0;

}

12 / 20

Category: (Java)

12. In a payment gateway system, retrying a failed transaction can cause data corruption if not handled carefully. What technique helps avoid this?

13 / 20

Category: (Java)

13. A bank application requires different types of accounts such as SavingsAccount and CurrentAccount. What OOP concept is used to achieve this?

14 / 20

Category: ( C++ )

14. What is the output of the following?

#include

int main() {

for (int i = 0; i < 5; ++i) { if (i == 3) continue; std::cout << i; } return 0; }

15 / 20

Category: ( C++ )

15. Which type of cast is considered safest in C++?

16 / 20

Category: ( C++ )

16. Which keyword is used to resolve ambiguity in multiple inheritance?

17 / 20

Category: (Java)

17. A car rental system has a Vehicle class with subclasses like Car and Bike. If Vehicle cannot be instantiated, which feature is being used?

18 / 20

Category: ( C )

18. What is the return type of the main function in C?

19 / 20

Category: ( C++ )

19. What is the output of this program?

#include

int main() {

const int x = 10;

int *ptr = const_cast(&x);

*ptr = 20;

std::cout << x; return 0; }

20 / 20

Category: ( C )

20. What will be the output of following program?

#include
void main()
{
if (printf("cisgood"))
printf("i know c");
else
printf("i know c++");
}

Scroll to Top