? Subjects Covered All Repeat Answers
? Subjects Covered All Repeat Answers
The document includes important repeat questions for the following 6th semester subjects:
1. Introduction to Cryptography
2. Java Programming I
3. Research Methodology
4. Software Engineering
5.
subject is organized into:
• Very Short Questions
• Short Questions
• Long Questions
All questions are marked as "All years" or with specific years like 2073–2081, indicating
their frequent appearance in exam
1. Define Cryptography.
Definition:
Cryptography is the science and art of transforming information to make it secure and
immune from unauthorized access. It involves techniques to secure communication in the
presence of adversaries.
Explanation:
It uses mathematical algorithms and protocols to encrypt (scramble) and decrypt
(unscramble) data to protect its confidentiality, integrity, authenticity, and non-repudiation.
Example:
When you send a message through WhatsApp, it uses end-to-end encryption, a
cryptographic technique, so only you and the receiver can read the message.
Substitution Cipher
Definition:
A substitution cipher replaces each element of the plaintext with another symbol or letter.
Types:
• Monoalphabetic: One-to-one mapping.
• Polyalphabetic: Uses multiple substitution alphabets.
Monoalphabetic Example:
Plaintext: ATTACK
Substitution key: A → Q, T → W, C → Z, K → M
Ciphertext: QWWQZM
Comparison:
Stream Cipher
Definition:
Encrypts data bit-by-bit or byte-by-byte using a keystream generator.
Characteristics:
• Suitable for real-time data (e.g., audio/video).
• Faster for small sizes.
• Example algorithms: RC4, Salsa20.
Differences Table
Use Cases:
• Block: File encryption, database encryption.
• Stream: Mobile communication, real-time streaming.
Features of AES
1. Block Size: 128 bits.
2. Key Sizes: 128, 192, or 256 bits.
3. Number of Rounds:
o 10 rounds for 128-bit keys
o 12 rounds for 192-bit keys
o 14 rounds for 256-bit keys
4. Symmetric: Same key used for encryption and decryption.
5. Fast and Secure: Highly efficient in both hardware and software.
6. Strong Security: Resistant to linear and differential cryptanalysis.
Example:
Suppose plaintext block and key are both 128 bits. AES performs a series of transformations
(as described above) to convert plaintext to ciphertext securely.
Euler’s Theorem
Statement:
If a and n are coprime (gcd(a, n) = 1), then:
aϕ(n)≡1mod na^{\phi(n)} \equiv 1 \mod naϕ(n)≡1modn
Where φ(n) is Euler’s totient function.
Example:
Let a = 3, n = 10
ϕ(10)=4,34=81mod 10=1\phi(10) = 4, \quad 3^4 = 81 \mod 10 = 1ϕ(10)=4,34=81mod10=1
Applications:
• RSA encryption
• Modular arithmetic
• Key exchange algorithms
Definition
A digital signature is a cryptographic technique used to validate the authenticity, integrity,
and non-repudiation of a digital message or document.
Receiver:
Message → Hash → Decrypt Signature (Public Key) → Compare Hashes
Applications:
• Digital contracts
• Secure emails
• Software distribution
Definition
Kerberos is a network authentication protocol designed to provide secure authentication for
users and services in a distributed environment using secret-key cryptography.
Kerberos Components
1. Key Distribution Center (KDC):
o Central authority.
o Issues tickets and session keys.
2. Authentication Server (AS):
o Verifies user credentials.
o Issues a Ticket-Granting Ticket (TGT).
3. Ticket Granting Server (TGS):
o Provides access tickets for other services using TGT.
Working of Kerberos
1. Login:
o User requests authentication from AS using username/password.
o AS issues TGT.
2. Service Request:
o User sends TGT to TGS requesting access to a service.
o TGS sends session key + ticket for the service.
3. Service Access:
o User sends service ticket to desired service.
o Service validates ticket and grants access.
Definition
SSL (Secure Sockets Layer) is a standard protocol used to establish a secure and encrypted
link between a web server and a web browser.
Modern systems use TLS (Transport Layer Security), an updated version of SSL.
Example:
When you access https://, SSL/TLS encrypts the session to protect login info, credit card
data, etc.
Continuing with the remaining Short Questions…
You said:
Continuing automatically
ChatGPT said:
Continuing with the remaining Short Questions (10 Marks Each) from Introduction to
Cryptography:
Definition
The Playfair cipher is a digraph substitution cipher developed by Charles Wheatstone and
promoted by Lord Playfair. It encrypts pairs of letters (digraphs) instead of single letters,
making it more secure than a monoalphabetic cipher.
GU I D A
NC E B F
HK L MO
P Q RS T
V WXY Z
Encrypting "ME":
• M (Row 2, Col 3), E (Row 1, Col 2)
• Rectangle Rule → New Letters: L (2,2), C (1,3) → LC
Encrypting "ET":
• E (1,2), T (3,4) → Rectangle → C (1,4), R (3,2) → BR
Encrypting "ME" again → LC
Ciphertext: LCBRLC
Definition
Elliptic Curve Cryptography (ECC) is a modern public-key cryptographic approach based on
the algebraic structure of elliptic curves over finite fields.
ECC Operations
1. Point Addition
2. Point Doubling
3. Scalar Multiplication
Advantages of ECC
• Smaller key size: 256-bit ECC = 3072-bit RSA.
• Faster computations
• Less memory and bandwidth
Applications
• Bitcoin & Blockchain
• Mobile encryption (e.g., Signal)
• TLS certificates (HTTPS)
Statement
The remainder theorem states:
If a polynomial f(x)f(x)f(x) is divided by x−ax - ax−a, then the remainder is f(a)f(a)f(a).
Formula
f(x)=(x−a)⋅Q(x)+R⇒R=f(a)f(x) = (x - a) \cdot Q(x) + R \quad \Rightarrow \quad R =
f(a)f(x)=(x−a)⋅Q(x)+R⇒R=f(a)
Example
Let f(x)=3x3+2x2−x+5f(x) = 3x^3 + 2x^2 - x + 5f(x)=3x3+2x2−x+5
Find the remainder when divided by x−2x - 2x−2:
f(2)=3(2)3+2(2)2−2+5=24+8−2+5=35f(2) = 3(2)^3 + 2(2)^2 - 2 + 5 = 24 + 8 - 2 + 5 =
35f(2)=3(2)3+2(2)2−2+5=24+8−2+5=35
Remainder = 35
Application in Cryptography
Used in modular arithmetic and polynomial division in error-correcting codes and
cryptographic algorithms (e.g., RSA).
Definition
Message integrity ensures that the data has not been altered during transmission. Hash
functions are used to verify integrity.
Process
1. Sender:
o Generates a hash H(M)H(M)H(M) of message MMM
o Sends both MMM and H(M)H(M)H(M) to the receiver.
2. Receiver:
o Computes hash H(M′)H(M')H(M′) of received message M′M'M′
o Compares it with received H(M)H(M)H(M)
3. If H(M)=H(M′)H(M) = H(M')H(M)=H(M′) → Message is intact.
Example
Message: "CSIT"
• Sender computes SHA-256("CSIT") = dfba12...
• Receiver does the same and compares hashes.
Applications
• Digital signatures
• Blockchain (each block’s hash links to previous block)
• Secure file transfer systems
Definition
Web security refers to the protection of web applications, websites, and web services from
cyber threats like unauthorized access, data breaches, or DDoS attacks.
Firewall
• Filters incoming/outgoing traffic based on rules.
• Acts as a barrier between internal network and external threats.
• Types: Packet filtering, stateful, proxy firewall.
Differences
Definition
Digital Signature Standard (DSS) is a federal standard (FIPS 186) that uses the Digital
Signature Algorithm (DSA) to generate and verify digital signatures.
Key Parameters
• p: Large prime number
• q: Prime divisor of p-1
• g: Generator
• x: Private key (random)
• y = g^x mod p: Public key
Signing Process
1. Choose random number kkk
2. Compute r=(gkmod p)mod qr = (g^k \mod p) \mod qr=(gkmodp)modq
3. Compute s=(k−1(H(m)+xr))mod qs = (k^{-1}(H(m) + xr)) \mod qs=(k−1(H(m)+xr))modq
4. Signature = (r,s)(r, s)(r,s)
Verification
1. Compute w=s−1mod qw = s^{-1} \mod qw=s−1modq
2. u1=H(m)⋅wmod qu_1 = H(m) \cdot w \mod qu1=H(m)⋅wmodq
3. u2=r⋅wmod qu_2 = r \cdot w \mod qu2=r⋅wmodq
4. v=((gu1⋅yu2)mod p)mod qv = ((g^{u_1} \cdot y^{u_2}) \mod p) \mod qv=((gu1⋅yu2
)modp)modq
5. If v=rv = rv=r, signature is valid.
SHA-512 Overview
• Part of the SHA-2 family.
• Produces 512-bit (64-byte) hash.
• Used in blockchain, digital signatures.
Features
• Message length: < 21282^{128}2128 bits
• Output length: 512 bits
• Secure against collision and pre-image attacks
• Better performance on 64-bit platforms
Padding in SHA-512
Padding ensures the message is a multiple of 1024 bits.
1. Append 1 bit
2. Append 0s until length ≡ 896 mod 1024
3. Append 128-bit message length
20. Explain DES encryption process and one round with features.
Overview
DES (Data Encryption Standard) is a symmetric key block cipher using 64-bit blocks and 56-
bit keys.
Features
• Block size: 64 bits
• Key size: 56 bits + 8 parity bits
• 16 rounds of Feistel cipher
Kerckhoffs's Principle
A cryptographic system should be secure even if everything about the system, except the
key, is public knowledge.
22. What are intruders? Differentiate between active and passive attacks.
Intruders
Entities attempting unauthorized access to systems for data theft or disruption.
Attack Types
24. Define double and triple DES. Explain the DES encryption process with a diagram.
5. Weaknesses of DES
• Short key length (56 bits)
• Vulnerable to brute-force attacks
• Deprecated for new systems
Solution: Use AES or 3DES for stronger security.
1. Overview
ElGamal is a public-key encryption algorithm based on the Discrete Logarithm Problem
(DLP). It provides semantic security, meaning same message → different ciphertexts.
2. Key Generation
1. Choose large prime ppp and generator ggg
2. Choose private key x∈[1,p−2]x \in [1, p-2]x∈[1,p−2]
3. Compute public key y=gxmod py = g^x \mod py=gxmodp
• Public key: (p,g,y)(p, g, y)(p,g,y)
• Private key: xxx
3. Encryption
To encrypt message mmm:
1. Choose random kkk
2. Compute:
o c1=gkmod pc_1 = g^k \mod pc1=gkmodp
o c2=m⋅ykmod pc_2 = m \cdot y^k \mod pc2=m⋅ykmodp
3. Ciphertext: (c1,c2)(c_1, c_2)(c1,c2)
4. Decryption
Given (c1,c2)(c_1, c_2)(c1,c2), compute:
m=c2⋅(c1x)−1mod pm = c_2 \cdot (c_1^x)^{-1} \mod pm=c2⋅(c1x)−1modp
5. Example
Let:
• p=17p = 17p=17, g=3g = 3g=3, x=15x = 15x=15
• y=315mod 17=6y = 3^{15} \mod 17 = 6y=315mod17=6
Message: m=13m = 13m=13
Random k=7k = 7k=7
• c1=37mod 17=11c_1 = 3^7 \mod 17 = 11c1=37mod17=11
• c2=13⋅67mod 17=13⋅15=195mod 17=8c_2 = 13 \cdot 6^7 \mod 17 = 13 \cdot 15 =
195 \mod 17 = 8c2=13⋅67mod17=13⋅15=195mod17=8
Ciphertext: (11,8)(11, 8)(11,8)
Decryption:
• c1x=1115mod 17=2c_1^x = 11^{15} \mod 17 = 2c1x=1115mod17=2
• 2−1mod 17=92^{-1} \mod 17 = 92−1mod17=9
• m=8⋅9=72mod 17=13m = 8 \cdot 9 = 72 \mod 17 = 13m=8⋅9=72mod17=13
6. Applications
• Used in PGP, GnuPG
• Secure key exchange protocols
26. Describe message authentication and the Modification Detection Code (MDC).
1. Message Authentication
Definition:
Ensures that the message:
• Is from a legitimate source (authenticity)
• Has not been altered (integrity)
2. Techniques
• Message Authentication Code (MAC)
• Digital Signature
• Hash-based authentication
4. Working
1. Sender computes hash H(M)H(M)H(M) and sends message + MDC
2. Receiver computes H(M′)H(M')H(M′) and compares with MDC
If hashes match → message is intact.
6. Examples
• SHA-256, SHA-512
• Used in:
o Software integrity verification
o File sharing systems (e.g., torrent hash)
27. Explain the AFS algorithm with features and block diagram.
1. AFS Overview
AFS (Andrew File System) is a distributed file system developed at Carnegie Mellon
University. It provides location transparency and security in accessing remote files.
2. Features
• Client-server architecture
• Strong authentication using Kerberos
• File caching
• Access control via ACLs (Access Control Lists)
3. AFS Security
AFS uses encrypted tokens issued by Kerberos for:
• User authentication
• File access control
4. Block Diagram
scss
CopyEdit
[User] -- Request --> [AFS Client] -- Request --> [AFS Server]
<-- Data (Encrypted using tokens) <--
5. Use Cases
• University campus networks
• Secure research data sharing
28. Discuss man-in-the-middle attack and Diffie-Hellman key exchange with example.
2. Process
1. Alice sends message to Bob.
2. Eve intercepts, modifies, and forwards it.
3. Both believe they’re communicating securely.
3. Example
Alice → Eve → Bob
Eve decrypts and reads messages, may alter them.
5. Steps
1. Public: Prime ppp, generator ggg
2. Alice picks private aaa, sends A=gamod pA = g^a \mod pA=gamodp
3. Bob picks bbb, sends B=gbmod pB = g^b \mod pB=gbmodp
4. Both compute shared key:
• Alice: K=Bamod pK = B^a \mod pK=Bamodp
• Bob: K=Abmod pK = A^b \mod pK=Abmodp
6. Example
• p=23p = 23p=23, g=5g = 5g=5
• Alice picks a=6a = 6a=6, A=56mod 23=8A = 5^6 \mod 23 = 8A=56mod23=8
• Bob picks b=15b = 15b=15, B=515mod 23=2B = 5^{15} \mod 23 = 2B=515mod23=2
• Shared key:
o Alice: 26mod 23=182^6 \mod 23 = 1826mod23=18
o Bob: 815mod 23=188^{15} \mod 23 = 18815mod23=18
7. MITM Risk in DH
• Without authentication, attacker can intercept AAA and BBB and send own values.
• Use digital signatures or certificates to prevent MITM.
Euler’s Theorem
If aaa and nnn are coprime, then:
aϕ(n)≡1mod na^{\phi(n)} \equiv 1 \mod naϕ(n)≡1modn
Where:
• ϕ(n)\phi(n)ϕ(n): Number of integers < n that are coprime to n.
Example:
• n=10n = 10n=10, ϕ(10)=4\phi(10) = 4ϕ(10)=4
• a=3⇒34=81mod 10=1a = 3 \Rightarrow 3^4 = 81 \mod 10 = 1a=3⇒34=81mod10=1
Applications
• RSA encryption
• Modular inverse computation
• Public key algorithms
Research & Methodology
According to the Far Western University CSIT 6th Semester syllabus
• Very Short Questions (3 Marks Each)
• Short Questions (10 Marks Each)
• Long Questions (12 Marks Each)
Definition:
A research problem is a clear, concise, and specific issue, situation, or gap in knowledge that
a researcher aims to address through systematic investigation.
Characteristics:
• Focuses on a real-world issue
• Has research significance
• Can be studied through scientific methods
Example:
Increased dropout rates in rural schools of Nepal due to lack of transportation can be a
research problem.
2. What is research?
Definition:
Research is a systematic, logical, and objective investigation to discover new facts, verify
existing knowledge, or solve problems by applying scientific methods.
Purpose:
• To explore (new ideas),
• To describe (current situations),
• To explain (causes and effects),
• To predict (future outcomes)
Example:
Analyzing the effect of internet addiction on academic performance of CSIT students.
Definition:
Scientific research is a systematic and objective process of collecting, analyzing, and
interpreting data to answer questions or solve problems based on empirical evidence and
logical reasoning.
Features:
• Empirical
• Measurable
• Replicable
• Follows scientific method
Types:
1. Exploratory Research:
o Conducted to explore a new problem or area where little information is
available.
o Flexible and open-ended.
o Example: Studying impact of AI on traditional job markets.
2. Descriptive Research:
o Describes characteristics of a population or phenomenon.
o Structured with defined objectives.
o Example: Survey on internet usage habits of university students.
Importance of Research:
1. Solves societal and technical problems:
o Research identifies causes and suggests solutions to challenges.
2. Generates new knowledge:
o Contributes to academic fields and industries.
3. Guides decision-making:
o Data-driven policies and strategies rely on research.
4. Improves educational quality:
o Encourages analytical thinking and innovation in students and teachers.
5. Validates existing theories:
o Confirms or contradicts past assumptions.
6. Supports economic and technological development:
o Fuels innovation and national growth.
Real-World Examples:
• Government using research to formulate climate change policy.
• Companies using market research to improve products.
Definition:
Report writing is the structured presentation of research findings in a clear, concise, and
formal manner.
Major Components:
1. Title Page
2. Abstract
3. Acknowledgements
4. Table of Contents
5. Introduction
6. Literature Review
7. Methodology
8. Data Analysis
9. Findings and Discussion
10.Conclusion and Recommendations
11.References/Bibliography
12.Appendices
Purpose:
• Communicates the purpose, process, and outcome of research
• Serves as a reference for future studies or decision-making
Definition:
A hypothesis is a testable statement or educated guess about the relationship between two
or more variables.
Characteristics:
1. Clear and specific
2. Testable and falsifiable
3. Based on theoretical framework
4. Relates variables
5. Directional or non-directional
Types:
• Null Hypothesis (H₀): No effect or relationship
• Alternative Hypothesis (H₁): There is an effect or relationship
Example:
H₀: Internet usage does not affect academic performance.
H₁: Increased internet usage negatively affects academic performance.
Example Scenarios:
• Interviewing teachers to understand challenges in online teaching.
• Discussing patient experiences in healthcare service delivery.
Ethical Issues:
1. Plagiarism
2. Fabrication of data
3. Privacy and confidentiality
4. Misuse of information
5. Harm to participants
Informed Consent:
A process in which participants are informed about:
• Purpose of the study
• What is expected from them
• Any potential risks or benefits
They must voluntarily agree to participate.
Examples:
• Primary: Conducting interviews with students
• Secondary: Using government education reports
Types of Research:
1. Basic (Pure) Research:
o Expands knowledge
o Example: Studying black holes in physics
2. Applied Research:
o Solves practical problems
o Example: Researching a vaccine for COVID-19
3. Descriptive Research:
o Describes characteristics of population
o Example: Census data
4. Analytical Research:
o Explains causes using existing data
o Example: Analyzing sales data to predict trends
5. Exploratory Research:
o Investigates new or vague problems
o Example: Exploring AI impact on ethics
6. Quantitative vs Qualitative:
o Quantitative: Numerical data (surveys, experiments)
o Qualitative: Descriptive data (interviews, case studies)
Definition:
Research design is the blueprint or plan for conducting research.
Elements:
1. Purpose of the study – exploratory, descriptive, etc.
2. Sampling design – method of selecting participants
3. Data collection methods – surveys, interviews
4. Measurement techniques – scales, questionnaires
5. Data analysis plan – statistical tools to be used
6. Timeframe and budgeting
15. What is the research problem? Provide guidance for selecting a good one.
Definition:
A research problem is a specific, well-defined issue that a researcher intends to address
through investigation.
“The Impact of Social Media Usage on Academic Performance among CSIT Students”
1. Introduction
Social media is deeply integrated into the daily lives of university students. While it
facilitates communication and access to educational resources, excessive or mismanaged
usage may distract students and harm academic performance.
2. Research Questions
1. Is there a significant relationship between social media usage and students’ academic
performance?
2. How does time spent on platforms like Facebook, TikTok, and Instagram affect GPA?
3. What types of social media usage (educational vs non-educational) are more
prevalent among students?
3. Hypotheses
• Null Hypothesis (H₀):
There is no significant relationship between social media usage and academic
performance.
• Alternative Hypothesis (H₁):
There is a significant negative impact of social media usage on academic
performance.
4. Objectives
• To measure time spent on social media by students.
• To assess academic performance using GPA.
• To identify correlation between usage patterns and GPA.
5. Methodology
a. Research Design:
Descriptive and Correlational Research
b. Population:
BSc CSIT students of Far Western University
c. Sample Size:
100 students selected using stratified random sampling (ensuring representation from each
semester)
d. Data Collection Methods:
• Structured Questionnaire (Time spent on social media, purpose, platforms used)
• Academic records (self-reported GPA)
e. Tools of Analysis:
• Descriptive statistics (mean, median)
• Correlation coefficient (Pearson’s r)
• Regression analysis
6. Expected Outcomes
• High social media usage may correlate with lower academic performance.
• Academic use of social media (e.g., YouTube lectures) may have positive effects.
7. Limitations
• Self-reported data may be biased.
• Limited to CSIT students—results not generalizable.
• Cannot prove causation, only correlation.
8. Ethical Considerations
• Informed consent will be taken.
• Confidentiality of participant data ensured.
Example in Research
Problem: Do long hours of mobile usage affect student concentration?
• Hypothesis: Yes, it reduces concentration.
• Method: Survey + performance test
• Result: Data supports the hypothesis
• Conclusion: Mobile addiction correlates with lower concentration
19. Describe the structure of a research report. List precautions during report writing.
Ethical Considerations
1. Informed Consent: Participants must be aware of the research purpose and
voluntarily participate
Example: Consent form signed before medical survey
2. Confidentiality and Anonymity: Personal information must be protected
Example: Survey responses stored without names
3. Plagiarism Avoidance: Credit all sources
Example: Use APA, MLA, or IEEE citation styles
4. Honest Reporting: Do not fabricate or falsify data
Example: Report actual survey results even if unexpected
5. Avoid Harm: Physical, psychological, or emotional harm must be avoided
Example: Avoid sensitive questions in trauma research
6. Voluntary Participation: No pressure to join or stay
Example: Allow participants to withdraw at any time
Importance of Ethics
• Builds trust
• Ensures validity and reliability
• Protects dignity of participants
• Promotes integrity in scientific community
Subject: Java Programming I
(Far Western University – BSc CSIT 6th Semester)
Very Short Questions (3 Marks Each)
1. What is JVM?
Definition:
The Java Virtual Machine (JVM) is a part of the Java Runtime Environment (JRE) that
enables Java bytecode to be executed on any machine, making Java a platform-
independent language.
Example:
java
CopyEdit
public class Hello {
public static void main(String[] args) {
System.out.println("Hello, JVM!");
}
}
• Compiled to: Hello.class (bytecode)
• Run using: java Hello → JVM executes
Definition:
The Scanner class in Java is used to read input from various input sources like keyboard,
files, strings, etc.
Key Uses:
• Reading different data types: int, float, String, etc.
• Simplifies input operations compared to older methods (BufferedReader)
Example:
java
CopyEdit
import java.util.Scanner;
4. Write a Java program to take name, age, and roll number input using Scanner class.
Program:
java
CopyEdit
import java.util.Scanner;
Output:
yaml
CopyEdit
Enter Name: Sita
Enter Age: 21
Enter Roll Number: 103
Return Type No return type Must specify return type (void, int)
Example:
java
CopyEdit
class Car {
String brand;
// Constructor
Car(String b) {
brand = b;
}
// Method
void show() {
System.out.println("Brand: " + brand);
}
}
Definition:
The super keyword in Java refers to the immediate parent class and is used for:
1. Accessing parent class constructor
2. Accessing parent class fields or methods that are overridden
Example:
java
CopyEdit
class Animal {
String type = "Animal";
void display() {
System.out.println("This is an animal.");
}
}
void printInfo() {
System.out.println(super.type); // Access parent variable
super.display(); // Call parent method
}
}
7. Write a Java program to input three numbers and find the greatest.
Program:
java
CopyEdit
import java.util.Scanner;
int greatest;
if(a >= b && a >= c)
greatest = a;
else if(b >= a && b >= c)
greatest = b;
else
greatest = c;
Definition:
Inheritance is an object-oriented principle where a class (child/derived class) inherits fields
and methods from another class (parent/base class).
Advantages:
1. Code Reusability
2. Method Overriding
3. Polymorphism
4. Extensibility
Example:
java
CopyEdit
class Animal {
void eat() {
System.out.println("Animal eats");
}
}
9. Explain the difference between interface and abstract class with examples.
Can have abstract and Only abstract methods (until Java 7),
Method Type
concrete methods default/static methods in Java 8+
Constructor
Can have constructors Cannot have constructors
Support
Interface Example:
java
CopyEdit
interface Vehicle {
void run();
}
Main Program:
java
CopyEdit
public class Demo {
public static void main(String[] args) {
MathOperation op = new MathOperation();
System.out.println(op.add(5, 10)); // Overloaded method
System.out.println(op.add(5, 10, 15));
Definition:
Exception Handling in Java is a mechanism to handle runtime errors so that the normal flow
of the program can be maintained.
Keywords:
• try: Block of code that might throw exception
• catch: Handles exception
• finally: Always executed (optional)
• throw: Manually throw exception
• throws: Declares an exception
Example:
java
CopyEdit
public class ExceptionDemo {
public static void main(String[] args) {
try {
int result = 10 / 0; // ArithmeticException
} catch (ArithmeticException e) {
System.out.println("Error: Cannot divide by zero");
} finally {
System.out.println("Execution completed");
}
}
}
Definition:
Garbage Collection (GC) in Java is the process of automatically reclaiming memory by
destroying objects that are no longer referenced.
How It Works:
• JVM automatically runs the garbage collector.
• It finds unreferenced objects and frees their memory.
Example:
java
CopyEdit
public class GarbageExample {
public static void main(String[] args) {
GarbageExample obj1 = new GarbageExample();
obj1 = null; // eligible for garbage collection
System.gc(); // request JVM to run GC
}
Advantages:
• Prevents memory leaks
• Improves application performance
• Reduces manual memory management burden
Definition:
An array in Java is a container object that holds a fixed number of values of a single type.
Syntax:
java
CopyEdit
type[] arrayName = new type[size];
Examples:
java
CopyEdit
// Integer array of size 5
int[] arr = new int[5];
// Assign values
arr[0] = 10;
arr[1] = 20;
// Initialization at declaration
String[] fruits = {"Apple", "Banana", "Cherry"};
// Print elements
for(String f : fruits) {
System.out.println(f);
}
Definition:
Autoboxing is the automatic conversion of a primitive type into its corresponding wrapper
class.
Example:
java
CopyEdit
int num = 10;
Integer obj = num; // autoboxing
System.out.println(obj); // prints 10
Similarly, Unboxing is the reverse:
java
CopyEdit
Integer val = 100;
int x = val; // unboxing
Use Case:
Autoboxing allows primitives to be used where objects are expected, e.g., in collections like
ArrayList<Integer>.
15. Write a Java program to input student details and display them using Scanner and
BufferedReader classes.
Using Scanner:
java
CopyEdit
import java.util.Scanner;
Using BufferedReader:
java
CopyEdit
import java.io.*;
16. Explain Java with respect to WWW and the Internet, highlighting key features.
Key Features:
1. Platform Independence:
o Java bytecode can run on any OS with JVM.
o Ideal for web applications accessed across platforms.
2. Applets and Web Integration:
o Java Applets (deprecated now) could be embedded in browsers.
3. Security:
o Java provides a secure runtime environment (sandbox model, classloader,
bytecode verifier).
4. Networking Support:
o Java supports TCP/IP protocols via java.net package (Sockets, URL, Datagram,
etc.)
5. Server-Side Programming:
o Java is widely used for backend web development:
▪ Servlets
▪ JavaServer Pages (JSP)
▪ Spring Framework
6. Support for Distributed Computing:
o RMI (Remote Method Invocation)
o CORBA integration
7. Multithreading:
o Java can handle multiple client requests using multithreading in web servers.
Conclusion:
Java’s strong support for networking, portability, and security has made it a pillar of web
development technologies for both client and server sides.
What is a Thread?
A thread is a lightweight subprocess, a small unit of a process. Java supports
multithreading, allowing multiple threads to run concurrently.
Creating Threads:
1. Extending Thread class
2. Implementing Runnable interface
t1.setPriority(Thread.MIN_PRIORITY); // 1
t2.setPriority(Thread.MAX_PRIORITY); // 10
t1.start();
t2.start();
}
}
Thread Priority:
Thread.MIN_PRIORITY 1
Thread.NORM_PRIORITY 5
Thread.MAX_PRIORITY 10
Higher priority threads are more likely to run first, but thread scheduling is JVM-
dependent.
Method Overriding:
Occurs when a subclass provides a specific implementation of a method that is already
defined in its parent class.
Example Program:
java
CopyEdit
class Animal {
void sound() {
System.out.println("Animal makes sound");
}
}
Car(String b) {
brand = b;
}
}
Method
• Called explicitly.
• Must have a return type.
• Performs specific task.
java
CopyEdit
class Car {
void show() {
System.out.println("This is a car.");
}
}
Comparison Table:
Feature Constructor Method
20. Explain the significance of packages and how to create custom packages in Java.
What is a Package?
A package is a namespace that organizes a set of related classes and interfaces.
Types:
1. Built-in packages: java.util, java.io, java.lang
2. User-defined (custom) packages
Benefits:
• Avoids name conflicts
• Easier maintenance
• Code modularity and reusability
• Access control
Compiling:
bash
CopyEdit
javac -d . Student.java
javac Main.java
java Main
Subject: Software Engineering
Definition:
Software Engineering is the application of engineering principles to the design,
development, testing, deployment, and maintenance of software systems.
Key Aspects:
• Systematic and disciplined approach
• Ensures software is reliable, efficient, scalable, and cost-effective
• Emphasizes planning, documentation, quality control, and project management
Example:
Developing a hospital management system using SDLC models like Waterfall or Agile.
Definition:
The Software Development Life Cycle (SDLC) is a structured process used for developing
software in a systematic, phased approach.
Phases of SDLC:
1. Requirement Analysis
2. System Design
3. Implementation (Coding)
4. Testing
5. Deployment
6. Maintenance
Key Characteristics:
• Correctness: Meets user requirements
• Reliability: Performs without failure
• Efficiency: Optimal use of resources
• Usability: Easy to learn and use
• Maintainability: Easy to fix bugs and add features
• Portability: Works across platforms
• Security: Protects against threats
Definition:
Prototyping is the process of building a working model of a software system that helps
users and developers visualize functionality and gather feedback before final development.
Types:
• Throwaway
• Evolutionary
• Incremental
• Extreme Prototyping (for web apps)
Cohesion:
• Degree to which elements of a module belong together
• High cohesion is desirable
Coupling:
• Degree to which one module depends on other modules
• Low coupling is desirable
Phases:
1. Requirement Analysis
2. System Design
3. Implementation
4. Testing
5. Deployment
6. Maintenance
Diagram:
nginx
CopyEdit
Requirements → Design → Implementation → Testing → Deployment → Maintenance
Advantages:
• Simple and easy to manage
• Well-documented
• Clear milestones
Disadvantages:
• Inflexible to change
• Late error discovery
• Not suitable for complex or evolving requirements
Knowledge
No knowledge of code Requires code knowledge
Required
Feature Black Box Testing White Box Testing
Equivalence partitioning,
Techniques Statement, branch, path coverage
boundary value
Spiral Model:
A risk-driven process model that combines iterative development with systematic aspects
of the Waterfall model.
Diagram:
sql
CopyEdit
Start → Planning → Risk Analysis → Engineering → Evaluation → Next Spiral
Advantages:
• Risk management
• Early customer feedback
• Flexible to change
Disadvantages:
• Complex to manage
• Costly for small projects
Definition:
Software maintenance involves modifying a software product after delivery to correct
faults, improve performance, or adapt to a new environment.
Types:
1. Corrective: Fixing bugs/errors
2. Adaptive: Adapting to environment changes (OS, hardware)
3. Perfective: Improving performance or adding new features
4. Preventive: Enhancing maintainability and preventing future issues
10. Explain software development life cycle (SDLC) with its phases.
(Already explained in Very Short Q2. Rewriting with more detail)
SDLC Phases:
1. Requirement Analysis: Understanding what the user needs
2. Design: Creating architecture and system design documents
3. Implementation: Writing code based on design
4. Testing: Verifying and validating software
5. Deployment: Releasing to users
6. Maintenance: Post-release bug fixes and updates
Agile Model:
Agile is an iterative and incremental software development model focused on flexibility,
collaboration, and customer satisfaction.
Phases of Agile:
1. Concept and Inception
2. Planning
3. Design
4. Development
5. Testing
6. Release
7. Feedback and iteration
Agile Practices:
• Daily stand-ups (Scrum)
• Sprint Planning and Reviews
• Continuous Integration
• Pair Programming
• Test-Driven Development (TDD)
Advantages:
• Quick delivery of working software
• Customer feedback included
• Adapts to change well
Disadvantages:
• Less predictability
• Requires high customer involvement
• Not ideal for large, rigid systems
Definition:
Software testing is the process of evaluating a software product to detect differences
between existing and required conditions (bugs, errors).
Levels of Testing:
1. Unit Testing: Test individual components/modules
2. Integration Testing: Test combined components
3. System Testing: Complete application testing
4. Acceptance Testing: Verifying against user needs (UAT)
Types of Testing:
• Manual Testing
• Automated Testing
Test Classifications:
Type Purpose
1. What is AJAX?
Definition:
AJAX (Asynchronous JavaScript and XML) is a web development technique used to send
and receive data from a server asynchronously without refreshing the web page.
Key Points:
• Improves user experience by updating only parts of the page
• Uses: XMLHttpRequest, Fetch API, or jQuery AJAX
• Can use JSON instead of XML
Definition:
A session in PHP is used to store user information across multiple web pages (e.g., login
status, cart info).
Example:
php
CopyEdit
session_start();
$_SESSION['user'] = "Ram";
echo $_SESSION['user'];
• session_start() must be called before output.
• Session data is stored on the server.
4. Define DOM.
Example:
HTML:
html
CopyEdit
<p id="demo">Hello</p>
JavaScript:
javascript
CopyEdit
document.getElementById("demo").innerHTML = "Hi!";
Purpose:
<!DOCTYPE html> tells the browser the HTML version to render. It ensures standards mode,
avoiding quirks in layout.
Differences:
• $_GET[]: Data visible in URL, less secure
• $_POST[]: Data sent in HTTP body, more secure
Cookies:
Cookies are small text files stored on the user's browser to remember information.
Syntax:
Set Cookie:
php
CopyEdit
setcookie("user", "Ram", time() + 3600); // 1-hour expiry
Access Cookie:
php
CopyEdit
echo $_COOKIE['user'];
Notes:
• Cookies are stored on client-side
• Can be used for preferences, sessions (light usage)
9. Explain the use of JavaScript in web development.
JavaScript Uses:
1. DOM Manipulation:
javascript
CopyEdit
document.getElementById("demo").style.color = "red";
2. Form Validation:
javascript
CopyEdit
if (name == "") alert("Name required");
3. AJAX Requests
4. Interactive UI:
o Sliders, popups, modals
5. Event Handling:
javascript
CopyEdit
button.onclick = function() { alert("Clicked!"); }
Example:
JSON:
json
CopyEdit
{ "name": "Ram", "age": 22 }
XML:
xml
CopyEdit
<student><name>Ram</name><age>22</age></student>
AJAX:
AJAX enables asynchronous data communication between client and server without page
reload.
Flow:
1. JavaScript triggers an AJAX request
2. Request sent to server (e.g., PHP file)
3. PHP processes and returns response
4. JavaScript updates webpage dynamically
Example:
HTML + JavaScript:
html
CopyEdit
<input type="text" id="name">
<button onclick="loadData()">Submit</button>
<p id="result"></p>
<script>
function loadData() {
var name = document.getElementById("name").value;
fetch("getdata.php?name=" + name)
.then(res => res.text())
.then(data => document.getElementById("result").innerHTML = data);
}
</script>
getdata.php:
php
CopyEdit
<?php
$name = $_GET['name'];
echo "Welcome, " . $name;
?>
What is a Session?
A session stores user-specific data between multiple pages.
Working:
1. Call session_start() at top
2. Use $_SESSION['key'] to store or retrieve
Example:
php
CopyEdit
// login.php
session_start();
$_SESSION['user'] = "admin";
echo "Logged in";
// dashboard.php
session_start();
echo $_SESSION['user']; // Displays "admin"
Advantages:
• Server-side storage
• Secure and persistent until destroyed or expired