Internship_Interview_Test_Java_C++
Internship_Interview_Test_Java_C++
Java MCQs
1. 1. What is the output of the following code?
```java
String s1 = "hello";
String s2 = new String("hello");
System.out.println(s1 == s2);
```
a) true
b) false
c) Compilation Error
d) Runtime Error
a) 2 bytes
b) 4 bytes
c) 8 bytes
d) Depends on OS
a) Method Overloading
b) Constructor Overloading
c) Method Overriding
d) None of the above
a) implements
b) inherits
c) extends
d) super
C++ MCQs
5. 5. What is the output of the following code?
```cpp
int a = 10;
int &b = a;
b = 20;
cout << a;
```
a) 10
b) 20
c) Compilation Error
d) Undefined
a) Java only
b) C++ only
c) Both
d) None
a) Memory optimization
b) Achieving runtime polymorphism
c) Faster execution
d) None of the above
a) int *p = malloc(sizeof(int));
b) int *p = new int;
c) int p = new int();
d) int p = malloc(int);
Create a class `Student` with attributes: name, roll number, and marks. Write methods to:
- Accept student details
- Display student details
Write a Java program with a base class `Vehicle` and a derived class `Car`. Add methods like
`startEngine()` and `displayDetails()`.
Write a C++ program to demonstrate constructor overloading with a class `Box` that can be
initialized:
- Without any parameters
- With one parameter
- With two parameters