0% found this document useful (0 votes)
4 views2 pages

Core Java Exam Answers

The document contains answers to a mid-semester examination on Core Java, covering key concepts such as Java's definition, interfaces, abstract classes, inheritance, inner classes, recursion, and vectors. It also outlines features of Java, differences between abstract classes and interfaces, and provides examples of ArrayList and inheritance. Additionally, it includes sample programs for determining even/odd numbers and checking Armstrong numbers.

Uploaded by

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

Core Java Exam Answers

The document contains answers to a mid-semester examination on Core Java, covering key concepts such as Java's definition, interfaces, abstract classes, inheritance, inner classes, recursion, and vectors. It also outlines features of Java, differences between abstract classes and interfaces, and provides examples of ArrayList and inheritance. Additionally, it includes sample programs for determining even/odd numbers and checking Armstrong numbers.

Uploaded by

jayzarad01
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

T.Y. B.B.

A (CA) - Core Java (CA-503)


Mid-Semester Examination Answers
Q.1 Attempt any Five (5×1=5 Marks)

1) What is Java?
Java is a high-level, object-oriented, secure, and platform-independent programming language. It
follows the principle of “Write Once, Run Anywhere (WORA)” using JVM.

2) Define Interface.
Interface is a collection of abstract methods and constants. It is used to achieve multiple
inheritance.
Example:
interface Shape { void draw(); }

3) What is meant by Abstract class?


Abstract class is a class declared with keyword abstract. It cannot be instantiated.
Example:
abstract class Animal { abstract void sound(); }

4) What is Inheritance?
Inheritance is the process of acquiring properties and behavior of one class into another.

5) What is Inner class?


Inner class is a class defined inside another class for logical grouping.

6) What is Recursion?
Recursion is a process where a method calls itself until a base condition is met.

7) What is Vector?
Vector is a legacy class in Java ([Link]). It implements resizable arrays.

Q.2 Attempt any Two (2×6=12 Marks)

1) Features of Java: Platform Independent, Object-Oriented, Robust, Secure, Multithreaded,


Portable.

2) Object as reference:
Object is an instance of class. In Java, variables store reference of objects.
Student s1 = new Student();

3) Difference between Abstract Class and Interface:


Abstract class: abstract + concrete methods, single inheritance, constructors allowed.
Interface: only abstract methods (till Java 7), supports multiple inheritance, no constructors.

4) ArrayList:
ArrayList is resizable array implementation of List interface.
ArrayList list = new ArrayList<>();

5) Inheritance Example:
Single Inheritance:
class Parent {} class Child extends Parent {}
Q.3 Attempt any One (1×5=5 Marks)

1) Even/Odd Program:
Scanner sc = new Scanner([Link]);
int n = [Link]();
if(n % 2 == 0) [Link]("Even"); else
[Link]("Odd");

2) Armstrong Program:
while(n > 0) { int d = n%10; sum += d*d*d; n /= 10; }
if(sum == temp) [Link]("Armstrong"); else
[Link]("Not Armstrong");

You might also like