0% found this document useful (0 votes)
34 views1 page

Heritage Institute of Technology: 4th Semester Class Test I Examination 2021 Session: 2020-2021

HERITAGE INSTITUTE OF TECHNOLOGY 4th Semester Class test I Examination 2021 Session : 2020-2021 Discipline : Information Technology Paper Code : INFO2202 Paper Name : Object Oriented Programming Time Allotted : 1 hr Full Marks : 30

Uploaded by

Ayush Bhowmick
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
34 views1 page

Heritage Institute of Technology: 4th Semester Class Test I Examination 2021 Session: 2020-2021

HERITAGE INSTITUTE OF TECHNOLOGY 4th Semester Class test I Examination 2021 Session : 2020-2021 Discipline : Information Technology Paper Code : INFO2202 Paper Name : Object Oriented Programming Time Allotted : 1 hr Full Marks : 30

Uploaded by

Ayush Bhowmick
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 1

HERITAGE INSTITUTE OF TECHNOLOGY

4th Semester Class test I Examination 2021 Session : 2020-2021


Discipline : Information Technology
Paper Code : INFO2202 Paper Name : Object Oriented Programming

Time Allotted : 1 hr Full Marks : 30

Figures out of the right margin indicate full marks.


Answer all the questions
Candidates are required to give answer in their own words as far as practicable.
1 (a) Predict the outputs of the following code snippets. Justify your answer. Comment if you think (2x2) + (6)
there will be compilation error. = 10
(i) class test {
public static void main(String a[]) {
for (int i = 0; 1; i++) {
System.out.println("How are you");
break;
}
System.out.println(i);
}
}
(ii) class testing {
public static void main(String[] a) {
String s1="Heritage", s2="Heritage";
if(s1==s2)
System.out.println("Equal”);
else
System.out.println("Inequal");
}
}
(b) Two strings, a and b, are called anagrams if they contain all the same characters in the same
frequencies. For example, the anagrams of CAT are CAT, ACT, TAC, TCA, ATC, and CTA.
Write a Java program which takes input of two strings a and b as input from command line;
If a and b are case-insensitive anagrams, print “Anagrams”
otherwise, print “Not Anagrams” instead. Take precaution against probable exception(s).
2 (a) What is the similarity between finally and finalize? (3) + (7) =
(b) Write a Java code to design a class to perform addition and subtraction of complex numbers. 10
This class should have different constructors to initialise the objects and the value of the
object should only be printed by overriding toString(). All instance variables should be private
and dynamically allocated.
3 (a) Demonstrate the difference between is-a, has-a, part-of relationships in Object Oriented (3)+(2)+
(b) Programming with code example. (2)+(3) = 10
Is Java a compiled or interpreted language? Justify your answer.
(c) Can the concept of interface be replaced with abstract class? Explain your answer.
(d) What do you mean by class variables? Why they are called so? Elaborate your answer with
supporting example.

You might also like