0% found this document useful (0 votes)
7 views4 pages

Java 2 Marks Answers

The document provides an overview of Object-Oriented Programming (OOP), including its definition, principles, and comparison with Procedural Programming. It covers key concepts such as JVM, JDK, identifiers, type casting, arrays, primitive data types, inheritance, interfaces, access specifiers, multiple inheritance, and packages in Java. Additionally, it includes examples and applications of OOP in real-world scenarios.

Uploaded by

gunaxd242
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)
7 views4 pages

Java 2 Marks Answers

The document provides an overview of Object-Oriented Programming (OOP), including its definition, principles, and comparison with Procedural Programming. It covers key concepts such as JVM, JDK, identifiers, type casting, arrays, primitive data types, inheritance, interfaces, access specifiers, multiple inheritance, and packages in Java. Additionally, it includes examples and applications of OOP in real-world scenarios.

Uploaded by

gunaxd242
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

21. Define Object-Oriented Programming (OOP).

2 CO1 K1
Object-Oriented Programming (OOP) is a programming paradigm based
on the concept of objects that contain data (variables) and methods
(functions) to perform operations. It focuses on modeling real-world
entities in software.
22. List any two principles of Object-Oriented Programming. 2 CO1 K1
Any two principles of OOP are:

1. Encapsulation
2. Inheritance

23. Differentiate between Procedural Programming and Object-Oriented 2 CO1 K2


Programming (any two points).
Procedural Programming Object-Oriented Programming
Focuses on functions and Focuses on objects and classes
procedures

Data and functions are separate Data and methods are bundled
together

24. What is JVM? State its purpose. 2 CO1 K2


JVM (Java Virtual Machine) is a virtual machine that executes Java
bytecode.
Its purpose is to make Java programs platform-independent and manage
memory and execution of Java programs.
25. Who developed Java and in which company? 2 CO1 K1
Java was developed by James Gosling at Sun Microsystems.
26. Define class and object. 2 CO1 K2
 Class: A class is a blueprint or template used to create objects.

 Object: An object is an instance of a class that represents a real-world


entity.
27. Give two real-world applications of Object-Oriented Programming. 2 CO1 K3
Two real-world applications of OOP are:

1. Banking systems (ATM, Online Banking)


2. E-commerce applications (Amazon, Flipkart)

28. What do you mean by JDK? 2 CO1 K1


JDK (Java Development Kit) is a software development kit used to develop
Java programs. It includes JRE, compiler (javac), and other development
tools.

29. What is an identifier? Write any two rules for naming identifiers. 2 CO2 K1
An identifier is the name given to a variable, class, or method.

Two rules:

1. It must not start with a digit.


2. It should not be a Java keyword (like int, class, if).

30. What is type casting? Mention its two types. 2 CO2 K1


Type casting is the process of converting one data type into another.

Two types:

1. Implicit casting (Widening)


2. Explicit casting (Narrowing)

31. What are command line arguments? 2 CO2 K1


Command line arguments are values passed to a program at the time of
execution through the command prompt.
32. Define unary and binary operators with one example each. 2 CO2 K1
 Unary operator: An operator that works on one operand.
Example: ++a

 Binary operator: An operator that works on two operands.


Example: a + b
33. Define array. Write one advantage of using arrays. 2 CO2 K1

An array is a collection of elements of the same data type stored in


contiguous memory locations.

Advantage: It allows storing multiple values using a single variable name.

34. What are the Primitive datatypes? 2 CO2 K2


The primitive data types in Java are:
byte, short, int, long, float, double, char, boolean.
35. What is the output of the following: 2 C02 K3
int a = 10, b = 5, c = 2;
int result = a + b * c - a / b + c;
[Link](result);

b * c = 5 × 2 = 10
a / b = 10 / 5 = 2

result = 10 + 10 − 2 + 2 = 20

36. Define inheritance and mention its types. 2 CO3 K1


Inheritance is the process by which one class acquires the properties of
another class.

Types of inheritance:

1. Single
2. Multilevel
3. Hierarchical
4. Multiple (through interface)
5. Hybrid

37. Distinguish between interface and abstract class (any two points). 2 CO3 K2

Can have Contains only abstract methods


abstract and
non-abstract
methods

Uses extends keyword Uses implements keyword

38. Write the purpose of access specifiers in Java. 2 CO3 K2


Access specifiers control the visibility and accessibility of classes, methods,
and variables in Java.
39. What is meant by multiple inheritance using interfaces? 2 CO3 K2
Multiple inheritance using interfaces means a class can implement more
than one interface and inherit their methods.
40. What is a package in Java? 2 CO3 K1
A package is a collection of related classes and interfaces grouped
together to organize code and avoid name conflicts.

You might also like