0% found this document useful (0 votes)
3 views3 pages

Java Unit I: Key Concepts & Structures

The document provides an overview of key concepts in Object-Oriented Programming (OOP) such as classes, objects, encapsulation, inheritance, polymorphism, and abstraction, along with their advantages. It outlines the structure of a Java program, including package declaration, import statements, class definition, and the main method. Additionally, it explains JavaDoc comments for documentation, the definition of two-dimensional arrays, and the structure for defining classes in Java.

Uploaded by

Sathish Sathish
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)
3 views3 pages

Java Unit I: Key Concepts & Structures

The document provides an overview of key concepts in Object-Oriented Programming (OOP) such as classes, objects, encapsulation, inheritance, polymorphism, and abstraction, along with their advantages. It outlines the structure of a Java program, including package declaration, import statements, class definition, and the main method. Additionally, it explains JavaDoc comments for documentation, the definition of two-dimensional arrays, and the structure for defining classes in Java.

Uploaded by

Sathish Sathish
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

Java Unit – I : Part A – 16 Mark Answers

1. What is Object-Oriented Programming?


Object-Oriented Programming (OOP) is a programming paradigm based on the concept of objects that
contain data (attributes) and methods (functions). It helps in organizing software into reusable, modular
components.

Key Concepts:
• Class – Blueprint for objects
• Object – Instance of class
• Encapsulation – Binding data & methods
• Inheritance – Reusing properties
• Polymorphism – One interface, many forms
• Abstraction – Hiding internal details

Advantages:
• Reusability, Modularity, Easy Maintenance, Security, Real-world modeling.

--------------------------------------------------

2. Outline the structure of a Java program.


Components:
• Package declaration
• Import statements
• Class definition
• Main method
• Program logic/statements

Example:
package sample;
import [Link].*;
class Demo {
public static void main(String[] args){
[Link]("Hello Java");
}
}

--------------------------------------------------

3. What is JavaDoc Comments?


JavaDoc comments are special multi-line comments used to generate documentation automatically in
HTML format. They begin with /** and end with */.

Tags:
• @param – Method parameter
• @return – Return type
• @author
• @version
• @throws

Example:
/**
* Adds two numbers
* @param a First number
* @param b Second number
* @return Sum of a and b
*/
int add(int a, int b) {
return a + b;
}

--------------------------------------------------

4. How to define a two-dimensional array in Java?

Declaration:
int[][] arr;

Creation:
arr = new int[3][4];

Initialization:
int[][] matrix = {
{1,2,3},
{4,5,6},
{7,8,9}
};

Accessing:
matrix[0][2]; // 3

--------------------------------------------------

5. Outline to define classes in Java.

Class Structure:
class ClassName {
// variables
// constructors
// methods
}

Example:
class Student {
int id;
String name;

Student(int i, String n){


id = i;
name = n;
}

void display(){
[Link](id + " " + name);
}
}

You might also like