0% found this document useful (0 votes)
2 views

Internship_Interview_Test_Java_C++

The document outlines an internship interview test focused on Java and C++, consisting of multiple-choice questions (MCQs) and coding tasks. It includes questions on Java features such as runtime polymorphism and class inheritance, as well as C++ topics like function overloading and memory allocation. Coding tasks require the creation of classes in both languages to demonstrate understanding of object-oriented programming principles.

Uploaded by

vijaydisale010
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Internship_Interview_Test_Java_C++

The document outlines an internship interview test focused on Java and C++, consisting of multiple-choice questions (MCQs) and coding tasks. It includes questions on Java features such as runtime polymorphism and class inheritance, as well as C++ topics like function overloading and memory allocation. Coding tasks require the creation of classes in both languages to demonstrate understanding of object-oriented programming principles.

Uploaded by

vijaydisale010
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Internship Interview Test: Java & C++

Part 1: MCQ Quiz (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

2. 2. What is the size of an `int` in Java?

 a) 2 bytes
 b) 4 bytes
 c) 8 bytes
 d) Depends on OS

3. 3. Which of the following is used for runtime polymorphism?

 a) Method Overloading
 b) Constructor Overloading
 c) Method Overriding
 d) None of the above

4. 4. Which keyword is used to inherit a class in Java?

 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

6. 6. Which of the following supports function overloading?

 a) Java only
 b) C++ only
 c) Both
 d) None

7. 7. What is the use of a virtual function in C++?

 a) Memory optimization
 b) Achieving runtime polymorphism
 c) Faster execution
 d) None of the above

8. 8. Which of these is a correct way to allocate memory dynamically in C++?

 a) int *p = malloc(sizeof(int));
 b) int *p = new int;
 c) int p = new int();
 d) int p = malloc(int);

Part 2: Coding Test

Java Coding Questions


9. 1. Class and Methods

Create a class `Student` with attributes: name, roll number, and marks. Write methods to:
- Accept student details
- Display student details

10. 2. Inheritance Example

Write a Java program with a base class `Vehicle` and a derived class `Car`. Add methods like
`startEngine()` and `displayDetails()`.

C++ Coding Questions


11. 3. Basic Class Example
Write a C++ program to define a class `Rectangle` with private members `length` and
`width`. Include methods to:
- Accept input
- Calculate and display area

12. 4. Constructor Overloading

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

You might also like