FUNDAMENTALS OF NETWORKING
In a cloud-based application where scalability is crucial, which cloud storage option allows dynamic scaling without manual intervention?
Options:
A. Block Storage
B. File Storage
C. ✅ Object Storage
D. Tape Storage=
✅ Correct Answer: C. Object Storage
Explanation of All Options:
💡 Quick Tip:
“Auto scaling = Object Storage”
Block = performance, File = sharing, Object = scalability, Tape = backup.
Q2: Which protocol is commonly used to secure data in transit over the internet?
Options:
(a) HTTP
(b) FTP
(c) ✅ SSL/TLS
(d) SMTP
✅ Correct Answer: (c) SSL/TLS
Explanation:
SSL (Secure Sockets Layer) and TLS (Transport Layer Security) are cryptographic protocols used to encrypt data during transmission between client and server, ensuring confidentiality, integrity, and authentication.
When SSL/TLS is applied to HTTP, it becomes HTTPS, which secures websites.
Other Options:
(a) HTTP: Transfers data in plain text — not secure.
(b) FTP: File transfer protocol — sends data unencrypted by default.
(d) SMTP: Used for sending emails — can use SSL/TLS for secure transmission (SMTPS), but itself is not encryption protocol.
Q2: Rate limiting is a strategy used to control the number of requests a user or client can make to an API within a specific time period. What is the primary purpose of implementing rate limiting?
Options:
(a) ✅ It prevents unauthorized access to the API
(b) It ensures that the API remains available and responsive for all users
(c) It allows developers to bypass authentication
(d) It increases the amount of data returned in each response
✅ Correct Answer: (a) It prevents unauthorized access to the API
Explanation:
Rate limiting is used to control API traffic and prevent abuse or denial-of-service (DoS) attacks. By limiting how many requests a user or client can make within a certain time, the API avoids being overloaded.
Although it doesn’t directly authenticate users, it adds a layer of protection against unauthorized or excessive requests — helping to keep the API stable and available.
Other Options:
(b) Ensuring API availability is a benefit, not the main purpose.
(c) Rate limiting never bypasses authentication; it works alongside it.
(d) It doesn’t affect how much data is sent — only how often requests are made.
💡 Trick:
“Authentication checks who you are — Rate limiting controls how much you can do.”
—----------------------------------------------------------------------------------------------------
Q3: Assume that you have recently started working for an organization that is transitioning to a cloud-based infrastructure. As part of IT governance, you are responsible for ensuring data security in the cloud environment. You need to choose the most secure cloud deployment model for an organization handling highly sensitive data. Which cloud deployment model is typically the most secure?
Options:
(a) Public Cloud
(b) ✅ Private Cloud
(c) Hybrid Cloud
(d) Community Cloud
✅ Correct Answer: (b) Private Cloud
Explanation:
A Private Cloud is owned, managed, and operated exclusively by a single organization. It offers dedicated resources, controlled access, and customized security policies, making it ideal for handling confidential or sensitive data (like finance, healthcare, or government information).
Organizations have full control over infrastructure, data governance, and compliance, reducing risks of data breaches compared to shared public environments.
Other Options:
(a) Public Cloud: Shared infrastructure; cost-effective but less control → higher exposure to threats.
(c) Hybrid Cloud: Mix of public + private; improves flexibility but security depends on proper integration.
(d) Community Cloud: Shared by similar organizations (e.g., banks, universities); secure but not as isolated as private.
—----------------------------------------------------------------------------------------------------------------
Q4: After initializing a connection attempt to a remote server, a client application sends a SYN packet to request a reliable connection. What is the expected response from the server, assuming it is available and ready to accept the connection?
Options:
(a) A FIN-ACK packet
(b) ✅ A SYN-ACK packet
(c) A RST packet
(d) An ACK packet
✅ Correct Answer: (b) A SYN-ACK packet
Explanation:
In TCP (Transmission Control Protocol), a three-way handshake is used to establish a reliable connection between client and server:
1️⃣ Client → SYN: Client sends a SYN packet to initiate connection.
2️⃣ Server → SYN-ACK: Server acknowledges with SYN-ACK (acknowledge + synchronize).
3️⃣ Client → ACK: Client sends an ACK confirming connection established.
So, the server’s expected response to a SYN packet is a SYN-ACK, signaling readiness to establish communication.
Other Options:
(a) FIN-ACK: Used during connection termination (not setup).
(c) RST: Sent when connection is refused or invalid.
(d) ACK: Used after SYN-ACK to complete handshake, not as first server response.
💡 Trick:
“SYN → SYN-ACK → ACK” = TCP connection established (3-way handshake).
-—--------------------------------------------------------------------------------------------------------
Q5: A network administrator is tasked with selecting a secure wireless encryption protocol. Which of the following is considered the most secure for Wi-Fi networks?
Options:
(a) WEP
(b) WPA2
(c) ✅ WPA3
(d) TKIP
✅ Correct Answer: (c) WPA3
Explanation:
WPA3 (Wi-Fi Protected Access 3) is the latest and most secure wireless encryption standard. It uses 128-bit or 192-bit encryption, Simultaneous Authentication of Equals (SAE) for stronger password protection, and improved defense against brute-force attacks. It also offers forward secrecy, meaning even if a password is compromised later, past data remains secure.
Other Options:
(a) WEP (Wired Equivalent Privacy): Outdated and easily hackable using basic tools.
(b) WPA2: Much stronger than WEP but still vulnerable to key reinstallation attacks (KRACK).
(d) TKIP (Temporal Key Integrity Protocol): Was used in WPA; now obsolete and insecure.
💡 Trick:
“WEP → Weak, WPA2 → Good, WPA3 → Best.”
Q:
Assume that a developer is tasked with configuring a high-security Wi-Fi environment for a sensitive government project using Android devices.
The configuration must leverage WPA-Enterprise security and the highest encryption settings (Suite-B-192) for compliance.
The given wpa_supplicant.conf snippet is:
CONFIG_SAE=Y
CONFIG_SUITEB=Y
CONFIG_SUITEB192=Y
In this scenario, which is the incorrect configuration line that might potentially weaken the desired security level?
Options:
A. ✅ CONFIG_SAE=Y is unnecessary since WPA-Enterprise does not integrate SAE.
B. CONFIG_SUITEB=Y is required to enable basic Suite-B cryptography.
C. CONFIG_SUITEB192=Y enables the highest level of security, Suite-B at 192-bit.
D. CONFIG_SUITEB=Y is redundant when CONFIG_SUITEB192=Y is also specified.
✅ Correct Answer: A. CONFIG_SAE=Y is unnecessary since WPA-Enterprise does not integrate SAE.
🧠 Explanation:
Other Options:
💡 Trick to Remember:
🔐 Enterprise = 802.1X (EAP)
🧩 SAE = WPA3-Personal only
⚙️ For max security → use SUITEB192, skip SAE!
Standard | Description | Status |
WEP (Wired Equivalent Privacy) | First Wi-Fi security method, uses static keys; easily hacked. | ❌ Outdated |
WPA (Wi-Fi Protected Access) | Replaced WEP, added TKIP encryption (temporary fix). | ⚠️ Weak |
WPA2 | Uses AES encryption, much stronger but vulnerable to KRACK attack. | 🟡 Standard for many networks |
✅ WPA3 | Latest and strongest — uses SAE (Simultaneous Authentication of Equals), 128/192-bit encryption, and Forward Secrecy. | ✅ Recommended |
Trick 🧩:
WEP → WPA → WPA2 → WPA3 = weak → better → strong → strongest 💪
🔒 “WEP Weak, WPA2 Okay, WPA3 Ace!”
Code snippet (example):
CONFIG_SAE=Y
CONFIG_SUITEB=Y
CONFIG_SUITEB192=Y
Incorrect Line:
✅ CONFIG_SAE=Y → Not needed for WPA-Enterprise; SAE is for WPA3-Personal.
Why?
Trick 💡:
🏢 Enterprise = 802.1X (no SAE)
🏠 Personal = SAE handshake
⚙️ “SuiteB192 = Strongest WPA3 mode”
⚡ Final Shortcut Recap:
—--------------------------------------------------------------------------------------------------------------------
Q6: Assume your computer's data was stolen by hackers through your network by mentioning the route to be used by the packets. This was done to bypass security measures since the firewall didn’t analyze the source information properly. What is this type of attack called?
Options:
(a) IP Address Spoofing
(b) ✅ Source Routing Attack
(c) Tiny Fragment Attack
(d) Drive-by Attack
✅ Correct Answer: (b) Source Routing Attack
Explanation:
A Source Routing Attack occurs when the attacker manually specifies the path that network packets should take through routers — instead of allowing routers to determine the best route.
By doing this, the hacker can bypass security devices like firewalls or intrusion detection systems, which rely on normal routing paths to inspect traffic.
This type of attack manipulates the IP header’s source routing option to avoid detection and exfiltrate data.
Other Options:
(a) IP Address Spoofing: Faking the source IP address to appear as a trusted system.
(c) Tiny Fragment Attack: Breaking malicious packets into small fragments to bypass firewall inspection.
(d) Drive-by Attack: Malicious code downloaded automatically when visiting a compromised website.
💡 Trick:
“When attacker controls the path of packets → it’s a Source Routing Attack.”
Q:
Hackers attempt to intercept and manipulate data packets traveling across a network by inserting malicious routing information, allowing them to redirect traffic through their own systems.
This enables them to eavesdrop or alter data without detection.
What type of attack is this called?
Options:
A. Packet Sniffing
B. IP Spoofing
C. DNS Spoofing
D. ✅ Routing Table Poisoning
✅ Correct Answer: (D) Routing Table Poisoning.
🧠 Explanation:
Other Options:
📡 Router ko bewakoof bana de → Routing Table Poisoning
🛣️ Packet me route likh de → Source Routing Attack
Packet Sniffing = just listens to traffic. — Trick: “Wiretap the wire.”
IP Spoofing = fake who sent it. — Trick: “Wear a fake sender mask.”
DNS Spoofing = fake the address book. — Trick: “Change the map, send them wrong.”
Routing Table Poisoning = break the routers’ map. — Trick: “Poison the map, reroute the road.”
Source Routing Attack = fake how it should travel. — Trick: “Tell the packet the path to take.”
Tiny Fragment Attack = split to hide payload. — Trick: “Slice small so the guard misses pieces.”
Drive-by Attack = visit site, get infected. — Trick: “Click the site, pick up the bug.”
ARP Poisoning = trick LAN name-to-MAC mapping. — Trick: “Swap name tags
On the local network.”
—------------------------------------------------------------------------------------------------------
Q7:
A web filtering service works with a firewall that stops user requests from leaving the network. The firewall queues the web filter, and based on the filter’s reply, it allows or denies the request.
Which of the following is not a disadvantage of using this service?
Options:
A. The firewall system has to ensure that all requests made by users are copied to the web filter system, causing excess use of resources.
B. Any malicious activity on one system is likely to affect the other system also.
C. If the web filter starts failing, the network connectivity of the system is tampered with because of the trust relationship between web filters and the firewall.
D. ✅ There is a trust relationship which exists between the firewall system and the web filter.
✅ Correct Answer: (D) There is a trust relationship which exists between the firewall system and the web filter.
Explanation:
Other Options:
💡 Trick:
“Trust relationship = necessary link, not a drawback.”
—-----------------------------
Q8:
Assume that a company wants to ensure secure and reliable email transmission for its cloud-based email service. Which protocol should they implement?
Options:
A. IMAP
B. POP3
C. ✅ SMTP
D. HTTPS
✅ Correct Answer: (C) SMTP (Simple Mail Transfer Protocol)
Explanation:
Other Options:
💡 Trick:
✉️ Send = SMTP
📥 Read/Receive = IMAP/POP3
🔒 Add “S” (TLS/SSL) for security → SMTPS, IMAPS, POP3S
—-----------------------------------------------------------------------------------------------------
Q9:
An enterprise is adopting a hybrid cloud model, where they combine on-premise infrastructure with public cloud services. To securely connect these environments and ensure data integrity, what solution should they implement?
Options:
A. Public Key Infrastructure (PKI)
B. ✅ Secure hybrid connectivity with VPN
C. Serverless architecture
D. Data encryption with asymmetric keys
✅ Correct Answer: (B) Secure hybrid connectivity with VPN
🧠 Explanation:
Other Options:
💡 Trick to Remember:
🔒 Hybrid cloud = 2 networks (private + public)
To link them securely → Use VPN (Virtual Private Network)
—------------------------------------------------------------------------------------------
Q10:
Which method is used to prevent unauthorized devices from connecting to a network?
Options:
A. ✅ MAC Filtering
B. DNS Spoofing
C. IP Forwarding
D. ARP Poisoning
✅ Correct Answer: (A) MAC Filtering
🧠 Explanation:
Other Options:
💡 Trick to Remember:
“MAC Filtering = MAC-based Access Control”
Only approved devices connect; others get blocked.
—------------------------------------------------------------------------------------------------------------
Q10:
Assume that an application relies on multiple hardware peripherals and requires strict isolation from other running containers to maintain data integrity and operational security.
To achieve this, the team configures the kernel so that each container is allocated specific hardware resources, limiting visibility of non-allocated devices to prevent unauthorized access.
What is the most critical factor in maintaining operational security and preventing resource contention among containers?
Options:
A. Ensuring that the host OS scheduler prioritizes CPU cycles equally for all containers.
B. ✅ Configuring the kernel to enforce strict resource isolation and limit peripheral access to only allocated devices for each container.
C. Using virtualization software to dynamically allocate additional memory resources to containers.
D. Allowing containers to share network interfaces to optimize data transmission rates.
✅ Correct Answer: (B) Kernel-level resource isolation and restricted device access
🧠 Explanation:
Thus, configuring the kernel to strictly enforce resource isolation is key.
Other Options:
💡 Trick to Remember:
🧱 “Container Security starts at the Kernel.”
Use Namespaces + cgroups → ensure isolation, not sharing.
—--------------------------------------------------------------------------------------------------------------------
Q11:
Assume that an employee at a multinational organization is working from home and needs to access the company’s internal network to retrieve some files.
Which type of Virtual Private Network (VPN) will be best suitable for this case?
Options:
A. ✅ Remote Access VPN
B. Site-to-Site VPN
C. MPLS VPN
D. PPTP VPN
✅ Correct Answer: (A) Remote Access VPN
🧠 Explanation:
Other Options:
💡 Trick to Remember:
🏠 Remote worker → Remote Access VPN
🏢 Office-to-office → Site-to-Site VPN
—-------------------------------------------------------------------------------------------------------
Q12:
Assume that in a cloud infrastructure that requires running multiple isolated environments on a single physical server, which technology is primarily used?
Options:
A. ✅ Virtual Machines
B. Containers
C. Bare Metal
D. Serverless
✅ Correct Answer: (A) Virtual Machines
🧠 Explanation:
Other Options:
💡 Trick to Remember:
🖥️ “One physical, many virtual = Virtual Machines.”
🧱 Containers → lightweight sharing;
🏗️ VMs → full isolation with own OS.
—---------------------------------------------------------------
Q13:
An organization has two geographically separate offices — Office A and Office B.
They need to allow all users in Office A to securely access resources in Office B, and vice versa,
as if both were on the same local network.
Which VPN topology is most appropriate for this scenario?
Options:
A. Remote Access VPN
B. Client-to-Site VPN
C. ✅ Site-to-Site VPN
D. SSL VPN
✅ Correct Answer: C. Site-to-Site VPN
🧠 Explanation:
Other Options:
—----------------------------------------------------------------------------------------------------
Q14:
Assume that an employee at a multinational organization is working from home and needs to access the company’s internal network to retrieve files.
Which type of Virtual Private Network (VPN) is best suitable for this scenario?
Options:
A. ✅ Remote-Access VPN
B. Site-to-Site VPN
C. MPLS VPN
D. PPTP VPN
✅ Correct Answer: A. Remote-Access VPN
🧠 Explanation:
Other Options:
—------------------------------------------------------------------------------------------
VPN Type | Use / Scenario | Shortcut Trick / Memory Aid |
Remote Access VPN | Individual user (like employee WFH) connects securely to company network. | 👨💻 “Single user → Remote Access” |
Site-to-Site VPN | Connects two or more office LANs securely over internet. | 🏢↔🏢 “Office-to-Office tunnel” |
Client-to-Site VPN | Similar to Remote Access; user (client) connects to company network. | 💻 “Client joins site” |
SSL VPN | Access apps securely via web browser (no full tunnel). | 🌐 “Login via browser” |
MPLS VPN | Used by ISPs for large enterprise WANs (faster, private routing). | 🚀 “Big companies’ private lane” |
PPTP VPN | Old VPN, insecure now. Avoid using. | 🕳️ “Pretty Poor Tunnel Protocol” 😅 |
IPSec VPN | Secure VPN that encrypts data at the network layer. | 🔐 “Strong tunnel – layer 3 security” |
Hybrid Cloud VPN | Connects on-premise data center to public cloud (Hybrid Cloud setup). | ☁️🏢 “Bridge between cloud & office” |
If an attacker can send a specially crafted message to one party and analyze the resulting encrypted message, which of the following techniques is most likely to compromise the secret key?
Options:
A. Analyzing patterns in intercepted encrypted messages
B. ✅ Comparing the crafted message's encrypted output with previous encrypted messages
C. Performing a brute force attack on intercepted messages
D. Matching message lengths to guess the content
✅ Correct Answer: B. Comparing the crafted message's encrypted output with previous encrypted messages
🧠 Explanation:
💡 Trick to Remember:
✉️ “If the attacker chooses the message → it’s a Chosen Plaintext Attack.”
They craft → encrypt → compare → crack 🔐
—--------------------------------------------------------------------------------------------------------------------
Q16:
Assume that an e-commerce website is experiencing sudden traffic spikes during a flash sale.
The platform needs to adjust resources automatically to handle the increased load without manual intervention.
Which cloud feature should be prioritized?
Options:
A. ✅ Auto-scaling
B. Static IP Allocation
C. Multi-tenancy
D. Load Balancing
✅ Correct Answer: A. Auto-scaling
🧠 Explanation:
Other Options:
💡 Trick to Remember:
☁️ Load Balancing = spread the load
⚙️ Auto-scaling = add/remove servers automatically
🔁 Auto-scaling = the cloud “auto-adjusts” itself to demand!
—--------------------------------------------------------------------------------------------------------------------
– OSI Model (Ethernet cables & Wi-Fi signals)
Q17:
Assume that an internet connection is established by a user.
This network connects a computer, smartphone, and smart TV to a router using Ethernet cables and Wi-Fi signals.
Which layer of the OSI model is responsible for connecting these physical media (cables/wireless)?
A. Physical Layer
B. Network Layer
C. Data Link Layer
D. Application Layer
A. Physical Layer
OSI Layer | Function | Example |
Physical Layer | Deals with actual transmission of bits over cables/waves — defines connectors, voltage, radio frequency | Ethernet cables, Wi-Fi signals, hubs, repeaters |
Data Link Layer | Handles MAC addressing, error detection, and framing | Switches, MAC address |
Network Layer | Handles IP addressing and routing | Routers, IP packets |
Application Layer | Deals with user-level services like browsers, emails | HTTP, FTP, SMTP |
🧩 “All People Seem To Need Data Processing”
Layer | Mnemonic Word | Function Example |
7️⃣ Application | All | Chrome, WhatsApp |
6️⃣ Presentation | People | Encryption, compression |
5️⃣ Session | Seem | Connection management |
4️⃣ Transport | To | TCP/UDP |
3️⃣ Network | Need | IP, routing |
2️⃣ Data Link | Data | MAC address, switch |
1️⃣ Physical | Processing | Cables, Wi-Fi, signal |
✅ Question 18:
Your marketing lead requests a list of employees from the South region for an internal campaign.
Which Excel formula allows you to generate this list dynamically from the dataset?
(You’re using Excel 365 or later, so dynamic array functions are supported.)
A. =IF(H2:H9="South", B2:B9)
B. =FILTER(B2:B9, H2:H9="South")
C. =XLOOKUP("South", H2:H9, B2:B9)
D. =INDEX(B2:B9, MATCH("South", H2:H9, 0))
B. =FILTER(B2:B9, H2:H9="South")
Formula | Function | Why It Works / Doesn’t |
IF(H2:H9="South", B2:B9) | Returns TRUE/FALSE with names — not dynamic array output | ❌ Only partial |
✅ FILTER(B2:B9, H2:H9="South") | Filters & returns all names from B2:B9 where region (H2:H9) = “South” | ✅ Correct |
XLOOKUP("South", H2:H9, B2:B9) | Returns only the first match | ❌ Not a list |
INDEX/MATCH | Returns only one record (first match) | ❌ Not dynamic |
If your dataset is:
Employee | Region |
Alice | East |
Bob | West |
George | South |
Hina | South |
✅ Formula →
=FILTER(B2:B9, H2:H9="South")
Output:
George
Hina
🧩 FILTER = Find All
💬 Use FILTER when you want all matches, not just the first one.
—----------------------------------------------------------------------------------------------------------
Question19:
Which Excel feature allows you to create custom calculations and summaries within a Pivot Table?
A. Calculated Fields
B. Calculated Items
C. Slicers
D. Grouping
A. Calculated Fields
Feature | Use Case | Example | Notes |
✅ Calculated Field | Used when you want to add a new formula/column inside a Pivot Table based on existing fields (columns). | Example: =Revenue - Cost → adds a new column “Profit” | Works on entire columns (fields) |
Calculated Item | Used to create a new item within a field (like a new category in “Region” or “Product”). | Example: Add a “Total North + South” item inside “Region” | Works on items within one field |
Slicers | Used for filtering Pivot Tables visually — like interactive buttons for categories. | Example: Click “South” to see only South region data. | Only filters data, no calculation |
Grouping | Used to combine rows/columns in a Pivot (e.g. group months into quarters or ages into ranges). | Example: Group “Jan, Feb, Mar” → “Q1” | Organizes data, doesn’t calculate |
Feature | Trick / Shortcut Memory |
🧮 Calculated Field | “New math formula” inside Pivot — works on columns |
🧩 Calculated Item | “New sub-item” inside one field |
🎚️ Slicer | “Interactive Filter Buttons” |
📦 Grouping | “Club things together” (e.g., months → quarters) |
Suppose Pivot Table fields:
You can add a Calculated Field like:
➡️ = Revenue - Cost
to create a new field “Profit” directly inside the Pivot Table.
In short:
🧮 Calculated Field → when you need a new column of custom calculations inside a Pivot Table.
—------------------------------------------------------------------------------------------------------------------
Question20:
In a corporate network, data packets are transmitted between routers and switches to ensure proper delivery across different segments. The OSI model is used to understand how data moves through the network.
Which layer of the OSI model is responsible for establishing logical paths and routing data packets between different network segments?
A. Data Link Layer
B. Network Layer
C. Transport Layer
D. Session Layer
B. Network Layer
OSI Layer | Function | Device Example | Keyword / Trick |
Physical | Transmission of raw bits via cables | Hubs, Cables | “Wire level” |
Data Link | Frame creation, MAC addressing, error detection | Switches, NIC | “Same room communication” |
✅ Network | Logical addressing (IP), routing between networks | Routers | “Finds the best route” |
Transport | Ensures reliable delivery, sequencing (TCP/UDP) | Gateways | “Delivery confirmation” |
Session | Manages sessions between applications | — | “Conversation keeper” |
Presentation | Data translation, encryption, compression | — | “Language translator” |
Application | User interface (HTTP, FTP, SMTP) | Browsers, Apps | “User interaction” |
🛰️ Network Layer = Routing Layer
→ It decides “how data travels” using IP addresses and routing tables between different networks.
So, routers work at the Network Layer, handling packet forwarding and path selection.
—--------------------------------------------------------------------------------------------------------------------
Question21:
Consider that in a cloud computing environment, which security measure helps protect user accounts by requiring them to provide two different types of identification before granting access?
A. Firewalls
B. Encryption
C. ✅ Multi-Factor Authentication
D. Antivirus Software
C. Multi-Factor Authentication (MFA)
Multi-Factor Authentication (MFA) adds an extra layer of security by requiring users to verify their identity using two or more factors before granting access.
👉 These factors are typically:
Even if one factor (like a password) is compromised, MFA prevents unauthorized access.
Option | Description | Why Incorrect |
🔥 Firewalls | Control incoming/outgoing traffic based on rules | Protects networks, not user identity |
🔒 Encryption | Converts data into unreadable form | Protects data, not login access |
🦠 Antivirus | Detects and removes malware | Protects devices, not authentication |
Question 22:
Consider that a small business uses a Ring Topology.
If a single workstation goes down, what impact will it have on the network?
A. Minimal impact, network reroutes traffic
B. Network becomes isolated
C. Network slows down
D. ✅ Network breaks completely
D. Network breaks completely
In a Ring Topology, each device is connected to exactly two other devices, forming a circular path.
➡️ Data travels in one direction (or both, in dual-ring).
➡️ If any single device or cable fails, the entire network breaks because the loop is interrupted.
📉 Hence, a single workstation failure = complete network failure.
Topology | Shape | Failure Impact | Speed | Trick/Keyword |
Bus | Straight line | One cable fails → all fail | Slow with more devices | 🚌 “Bus me sab connected — ek wire gaya, sab gaya” |
Ring | Circle 🔁 | One break → network breaks | Fast until failure | 💍 “Ring toot gaya, connection loot gaya” |
Star | Central hub ⭐ | Hub fails → all fail, node fails → safe | Fast | ⭐ “Star me center hero — hero gaya, show gaya” |
Mesh | Fully connected web 🕸️ | Very reliable | Very fast but costly | 🕸️ “Mesh me har koi connected — backup ready!” |
Tree | Hierarchical 🌳 | Branch down = partial fail | Medium | 🌳 “Tree me ek branch gaya, poora tree nahi” |
Hybrid | Mix of topologies | Depends on type | Flexible | 🔄 “Hybrid = Mix of best” |
Option | Meaning | Why Incorrect |
Authentication | Verifies who you are (like password, OTP) | Checks identity, doesn’t hide data |
Authorization | Decides what you can access after login | Controls access rights |
Compression | Reduces data size for faster transfer | Saves space, not security |
Assume that an application relies on a series of hardware peripherals and requires strict isolation from other running containers to maintain data integrity and operational security.
To ensure this, the development team implements a kernel-level configuration where each container is allocated specific hardware resources, limiting visibility of non-allocated devices.
What is the most critical factor in maintaining operational security and preventing resource contention among containers?
(a) Ensuring that the host OS scheduler prioritizes CPU cycles equally for all containers
(b) ✅ Configuring the kernel to enforce strict resource isolation and limit peripheral access to only the allocated devices for each container
(c) Using virtualization software to dynamically allocate additional memory resources
(d) Allowing containers to share network interfaces to optimize transmission rates
👉 (b) Configuring the kernel to enforce strict resource isolation and limit the peripheral access
—------------------------------------------------------------------------------------------------------------------------
Question25):
Assume a network administrator wants to assign IP addresses dynamically to devices in a network. Which protocol (introduced in 2003) is used for this purpose?
A. DNS
B. DHCP
C. ARP
D. ICMP
B. DHCP (Dynamic Host Configuration Protocol)
Step | Full Form | Description |
D | Discover | Client broadcasts request for IP. |
O | Offer | DHCP server offers an available IP. |
R | Request | Client requests to use that IP. |
A | Acknowledge | Server confirms and assigns IP. |
🔁 (DORA = DHCP handshake process)
Protocol | Purpose | Trick |
DNS | Converts domain name → IP | “Name to Number” |
ARP | Finds MAC address from IP | “Who has this IP?” |
ICMP | Error reporting (e.g. ping) | “Hey! Are you alive?” |
DHCP | Gives IP dynamically | “I’ll give you an address!” |
—------------------------------------------------------------------------------------------------------------------------
Question25):
A startup is concerned about unpredictable expenses due to variable cloud usage.
Which cloud feature should they implement to manage and predict costs more accurately?
A. Auto-scaling
B. Reserved Instances
C. Load Balancing
D. Content Delivery Network (CDN)
B. Reserved Instances
Option | Description | Why Not Correct |
Auto-scaling | Automatically adds/removes servers based on demand | Good for performance, but costs can fluctuate |
Load Balancing | Distributes traffic evenly | Improves efficiency, not cost predictability |
CDN | Speeds up content delivery globally | Focuses on latency, not billing consistency |
“If you want stable bills, make a reservation — Reserved Instances 🔒💵”
—----------------------------------------------------------------------------------------------------------
Question 26):
Assume a company needs a security solution where the firewall acts as an intermediary, inspecting all outgoing and incoming traffic between the user’s device and the internet.
Which type of firewall is most suitable for this requirement?
(a) Packet Filtering Firewall
(b) ✅ Proxy Firewall
(c) Circuit-Level Gateway
(d) Application Firewall
🧱 “Proxy = Parda (middleman)”
If the firewall sits between user and internet — checking everything like a parda (screen) before passing —
it’s always a Proxy Firewall!
🧭 Example:
When you visit a website — request goes → Proxy Firewall → Internet → back through Proxy Firewall.
It checks everything both ways 🔄.
Firewall Type | OSI Layer | What it Does | 🎯 Trick |
Packet Filtering | 3 (Network) | Checks IPs, ports | “Fast but blind” 👀 — sees header only |
Circuit-Level Gateway | 5 (Session) | Validates connection | “Handshake checker” 🤝 |
Proxy Firewall ✅ | 7 (Application) | Full inspection, hides user | “Middleman mask” 😷 |
Application Firewall | 7 | App-specific filter | “Doctor for one app only” 💉 |
COMPUTER SCIENCE
Options:
A. POST
B. PUT
C. DELETE
D. ✅ GET
✅ Correct Answer: D. GET
Explanation of All Options:
HTTP Methods – Short Notes (for quick revision):
Q2 : Which concept is being used in the given code?
class A {
int a;
void sum() {
a++;
}
void sum(int a) {
a = a + a;
}
};
Options:
(a) Abstraction
(b) Encapsulation
(c) Inheritance
(d) ✅ Polymorphism
✅ Correct Answer: (d) Polymorphism
Explanation:
Other Options (for revision):
💡 Quick Tip:
“Same name, different form = Polymorphism”
Overloading → Compile-time,
Overriding → Runtime.
Q3: During the development of an application, a developer encounters an error message indicating that the API endpoint they are trying to access is not found.
Which HTTP status code is most likely associated with this error?
Options:
A. 404
B. 500
C. 403
✅ Correct Answer: A. 404 (Not Found)
Short Explanation:
Trick: “1xx = Message Received, Work in Progress”
Trick: “2xx = All Good”
💡 Remember: “2xx = Green Signal ✅”
Trick: “3xx = Chalo idhar se jao!”
💡 Remember: “3xx = Redirect kar diya.”
Trick: “4xx = Client ki galti”
💡 Remember:
404 = "Lost Path"
403 = "Gate Closed"
401 = "ID Missing"
Trick: “5xx = Server ki galti”
💡 Remember:
“5xx = Not your fault, server ki fault.”
Q4:
Assume that a Java application having a class name TeaMac that can handle different types of tea. The class has a method to boil tea based on the tea selected.
public class TeaMac {
public Coffee boilTea(ChooseTea choosed) {
switch (choosed) {
case GREEN_TEA:
return boilgreentea();
default:
// default code
}
}
public List boilTea(ChooseTea choosed) {
List teas = new ArrayList(number);
for (int i=0; i<number; i++) {
teas.add(boilTea(choosed));
}
return teas;
}
}
Options:
(a) ✅ Static polymorphism
(b) Dynamic polymorphism
(c) Late binding
(d) Method overriding
✅ Correct Answer: (a) Static Polymorphism
Explanation:
Other Options:
(b) Dynamic polymorphism: Runtime pe decide hota hai → jab child class parent ki method ko override karti hai.
(c) Late binding: Runtime binding = dynamic polymorphism hi hota hai.
(d) Method overriding: Jab subclass parent class ki same signature wali method redefine kare → ye bhi runtime polymorphism hai.
🧠 Quick Notes:
💡 Trick:
“Compile-time = Overloading (same class)”
“Runtime = Overriding (different class)”
Q:5
During deployment, assume a DevOps engineer observes that a containerized application experiences high latency.
What approach should the engineer take first to rectify the issue?
Options:
A. Increase the CPU and memory limits
B. ✅ Analyze the network traffic and logs
C. Restart the container
D. Reduce the number of containers
✅ Correct Answer: B. Analyze the network traffic and logs
Short Explanation:
Other Options:
💡 Trick:
“DevOps mantra: Investigate before you scale.”
Logs → Metrics → Then tuning.
Q6: When a successful build in the Continuous Integration pipeline, assume that the compiled and packaged application (e.g., a JAR file, Docker image, or rpm package) needs to be stored in a central, versioned repository. This ensures that only approved, tested, and immutable binaries are used for deployments to various environments (development, staging, production). Which DevOps building block addresses the secure storage, versioning, and retrieval of these build outputs?
Options:
(a) Source Code Management
(b) Database Management
(c) ✅ Artifact Management
(d) Container Orchestration
✅ Correct Answer: (c) Artifact Management
Explanation:
Artifact Management securely stores, versions, and retrieves build outputs like JARs, Docker images, or RPMs to ensure consistent, tested, and immutable artifacts are deployed.
Tools include JFrog Artifactory, Sonatype Nexus, and AWS CodeArtifact.
Other Options:
(a) Source Code Management – handles source code (Git, SVN), not build binaries.
(b) Database Management – manages structured data, not application builds.
(d) Container Orchestration – manages container deployment and scaling (Kubernetes), not artifact storage.
💡 Trick:
“SCM = Source | Artifact Repo = Build Output | Orchestration = Deployment.”
Q7: What will be the output of the given code when the user clicks the button?
<body>
<button onclick="myFunction(this)">Test onclick attribute!</button>
<script type="text/javascript">
function myFunction(button) {
document.write(button.getAttribute("onClick", 1));
}
</script>
</body>
Options:
(a) True
(b) False
(c) ✅ myFunction(this)
(d) None of the given options
✅ Correct Answer: (c) myFunction(this)
HTML me ek button banaya gaya hai:
<button onclick="myFunction(this)">
🔹 Step 2: this ka matlab kya hai?
document.write(button.getAttribute("onClick", 1));
Button ke andar likha tha:
onclick="myFunction(this)"
So getAttribute("onClick") ye string return karega:
myFunction(this)
To jab button click karega, output banega 👇
myFunction(this)
Agar function me likha hota:
button.getAttribute("id")
Aise question me hamesha soch:
👉 Step 1 – Function kab call ho raha hai?
👉 Step 2 – Parameter kya pass hua (this)?
👉 Step 3 – getAttribute() kya fetch kar raha hai?
👉 Step 4 – document.write() kya print karega?
—---------------------------------------------------------------------------------------------------------------------------------------------------------
Q8: Assume that in a grocery store, the management wants a Java program to manage and display item types in stock. A Java class GroceryStore is written to create instances for “Apple” and “Milk”, using constructors with no parameters and one parameter respectively. What will be the correct output of this program?
class GroceryStore {
String itemType;
GroceryStore() {
itemType = "Apple";
}
GroceryStore(String itemType) {
this.itemType = itemType;
}
public void getItemType() {
System.out.println("Item Type: " + itemType);
}
public static void main(String[] args) {
GroceryStore obj1 = new GroceryStore();
GroceryStore obj2 = new GroceryStore("Milk");
obj1.getItemType();
obj2.getItemType();
}
}
✅ Output:
Item Type: Apple
Item Type: Milk
Explanation:
💡 Trick:
“Constructor with no args → default value, Constructor with args → custom value.”
—---------------------------------------------------------------------------------------
Q9:
An e-commerce company updates its website weekly by adding new features and fixing bugs using an Agile development approach.
After each update, the new version is automatically deployed to the live environment.
Which key DevOps practice is being implemented to ensure rapid and frequent releases?
Options:
A. The practice involves automating the process of releasing software to production frequently and reliably.
B. Continuous Integration focuses on merging code changes regularly to prevent conflicts.
C. Continuous Testing ensures that automated tests are run continuously to validate code quality.
D. Monitoring involves tracking the application's performance and user activity after deployment.
✅ Correct Answer: (A) Continuous Deployment (or Continuous Delivery)
🧠 Explanation:
Other Options:
—---------------------------------------------------------------------------------------------------------------------------------
Q10:
You are configuring Jest to run tests with specific command-line options for coverage reporting and test execution.
Which Jest command-line option would you use to generate a coverage report in HTML format?
Options:
A. coverageReporters text.html
B. collectCoverage true coverageReporters=text,html
C. ✅ --coverage --coverageReporters=text,html
D. --collectCoverageFrom=src --coverageFilesReporters=text.html
✅ Correct Answer: (C) --coverage --coverageReporters=text,html
🧠 Explanation:
Example Command:
jest --coverage --coverageReporters=text,html
Other Options:
💡 Trick to Remember:
🧪 For Jest CLI:
✅ --coverage → to collect data
✅ --coverageReporters=html → to view it visually in browser
—---------------------------------------------------------------------------------------------------------------------------------
Q11:
Assume a development team is designing a RESTful API to manage a product catalog for an e-commerce platform.
They need to create an endpoint that retrieves detailed information about a specific product using its unique product ID.
Which HTTP method and URL structure best aligns with RESTful principles for this operation?
Options:
A. POST /products/{id}/details
B. GET /product.details?id={id}
C. PUT /products/{id}/fetch
D. ✅ GET /products/{id}
✅ Correct Answer: D. GET /products/{id}
🧠 Explanation:
—------------------------------------------------------------------------------------------------
Q12:
An enterprise is adopting a hybrid cloud model, combining on-premise infrastructure with public cloud services.
To securely connect these environments and ensure data integrity, what solution should they implement?
Options:
A. Public Key Infrastructure (PKI)
B. ✅ Secure hybrid connectivity with VPN
C. Serverless Architecture
D. Data Encryption with Asymmetric Keys
✅ Correct Answer: B. Secure Hybrid Connectivity with VPN
🧠 Explanation:
Other Options:
—----------------------------------------------------------------------------------------------------------------------------------------------
Q13:
Assume a DevOps engineer notices that a containerized application consumes excessive memory, leading to performance issues.
What is the recommended approach to address this issue?
Select the correct option from the given choices.
Options:
A. Increase the memory limit for the container
B. Use a larger base image for the container
C. Reduce the number of replicas of the container
D. ✅ Analyze the application code for memory leaks
✅ Correct Answer: D. Analyze the application code for memory leaks
🧠 Explanation:
Other Options:
💡 Trick to Remember:
🧠 “If memory grows without reason → it’s leaking season!”
Always debug → profile → fix the code, not just add more memory.
—-------------------------------------------------------------------------------------------------------------------------------------------
Question14):
Consider that a team wants to improve deployment speed and reduce downtime when updating their containerized application.
Which practice should the team adopt in this scenario?
(a) Increase the number of replicas
(b) Disable the health checks
(c) ✅ Use rolling updates with health checks
(d) Use a larger base image
Practice | Purpose | Trick |
Rolling updates ✅ | Zero-downtime deployment | “Change tires one by one” 🚗 |
Health checks ✅ | Ensure app is alive | “Ping before trust” 🩺 |
Blue-Green Deployment | Alternate environments | “Two tracks — one live, one standby” 🟦🟩 |
Canary Release | Gradual rollout to users | “Send one bird first” 🐦 |
COMMON APPLICATIONS
Q1: Assume a developer writes a program that needs to create a new process and run a different executable file. Which pair of system calls in a UNIX OS fulfill this requirement?
Options:
(a) create() and run()
(b) ✅ fork() and exec()
(c) fork() and wait()
(d) spawn() and terminate()
✅ Correct Answer: (b) fork() and exec()
Explanation: fork() creates a new child process (a copy of the parent). After that, exec() replaces the child’s memory with a new executable program, effectively running a different file. This combo is the standard way to create and execute a new process in UNIX.
Other Options:
(a) create() and run(): No such system calls in UNIX.
(c) fork() and wait(): Used when parent waits for child to finish, not to run a new executable.
(d) spawn() and terminate(): Used in Windows OS, not UNIX.
💡 Trick: > “In UNIX: fork → clone, exec → replace.”
—-------------------------------------------------------------------------------------------------------------------
Q2: You're building a training module in MS PowerPoint and want to restrict navigation so that each slide is viewed sequentially with narration. Which setting provides the desired control?
Options:
(a) Add hyperlinks to the "next" button and "prev" navigation
(b) Disable "click to advance" and use "custom show"
(c) ✅ Enable "Browsed at a kiosk (full screen)" mode
(d) Use "Loop continuously" with auto transitions
✅ Correct Answer: (c) Enable "Browsed at a kiosk (full screen)" mode
Explanation:
The “Browsed at a kiosk (full screen)” option in PowerPoint locks the presentation so users can’t manually skip slides by clicking or pressing keys. Navigation can only happen using action buttons or links that you define — perfect for training modules, quizzes, or guided tutorials with narration.
Other Options:
(a) Hyperlinks (Next/Prev): Allow navigation, but don’t restrict users from skipping slides manually.
(b) Disable click + Custom show: Useful for specific slide sequences, but not for restricting all navigation.
(d) Loop continuously: Just restarts the presentation automatically; doesn’t enforce sequence or control navigation.
💡 Trick:
“For controlled, step-by-step PowerPoint flow → Use Kiosk Mode.”
—------------------------------------------------------------------------------------
Q3:
As a computer architect, you are designing the control unit of a CPU. You need to specify how data is moved from the accumulator to the memory. Which of the following best describes this operation?
Options:
(a) The process of transferring data from the accumulator to memory is called a register transfer.
(b) The process of transferring data from the accumulator to memory is called a memory read operation.
(c) ✅ The process of transferring data from the accumulator to memory is called a memory write operation.
(d) The process of transferring data from the accumulator to memory is called an instruction fetch.
✅ Correct Answer: (c) Memory Write Operation
Explanation:
Other Options:
💡 Trick:
“CPU → Memory = Write”
“Memory → CPU = Read”
—------------------------------------------------------------------------------------------------------------
Q4:
To create a document template for repeated use, which of the given file formats should you save the document in?
Options:
A. .doc
B. .docx
C. ✅ .dotx
D. .txt
✅ Correct Answer: (C) .dotx
🧠 Explanation:
Other Options:
💡 Trick to Remember:
“T” in .dotx = Template
Use .dotx for reusable document designs.
—------------------------------------------------------------------------------------------------
Q5:
In a computer system, data is transferred between the CPU and peripheral devices through a shared bus controlled by device controllers.
To improve data transfer speed and reduce latency, the system incorporates controllers with dedicated high-speed buffers.
Which of the following device controllers is most suitable for this purpose?
Options:
A. Wireless Controller
B. USB (Universal Serial Bus) Controller
C. ✅ SATA (Serial Advanced Technology Attachment) Controller
D. Ethernet Controller
✅ Correct Answer: (C) SATA (Serial Advanced Technology Attachment) Controller
🧠 Explanation:
Other Options:
—----------------------------------------------------------------------------------------------------------------------------
Q6:
Jane wants to create a slide that illustrates a progression over time using icons, text, and lines.
She wants it to look visually dynamic without manually animating each step.
Which MS PowerPoint feature can help speed up this process?
Options:
A. Use Slide Zoom feature to create dynamic progress slides quickly.
B. Use SmartArt Process layout and apply by Paragraph animation.
C. ✅ Apply the Morph transition across duplicated slides for smooth flow.
D. Create a custom layout with background images and animation triggers.
✅ Correct Answer: (C) Apply the Morph transition across duplicated slides for smooth flow.
🧠 Explanation:
Other Options:
💡 Trick to Remember:
🌀 “Morph = Magic Move” → smooth, automatic animation between similar slides.
—-------------------------------------------------------------------------------------------------------------------
Q7:
During a context switch, the OS saves the state of the currently running process and loads the state of the next one.
Which crucial CPU register, responsible for holding the address of the next instruction to be fetched, must be saved and restored during this operation?
Options:
A. Stack Pointer (SP)
B. General Purpose Register (GPR)
C. ✅ Program Counter (PC)
D. Instruction Register (IR)
✅ Correct Answer: (C) Program Counter (PC)
🧠 Explanation:
Other Options:
💡 Trick to Remember:
🧠 PC = “Program’s Current location” — tells CPU where to go next!
In context switch → Save PC = “pause location”, Restore PC = “resume here”.
—-------------------------------------------------------------------------------------------------------------
Q8:
Consider that a software development team is implementing containerization to drive application deployment by encapsulating applications and their dependencies.
What characteristic separates containers in the context of software development and deployment?
Select the correct answer from the given choices.
Options:
A. Lightweight VMs with a dedicated hypervisor
B. A logically separate network within servers
C. ✅ Part of the same OS instance as the hypervisor
D. Virtual computers running under a hypervisor
✅ Correct Answer: C. Part of the same OS instance as the hypervisor
🧠 Explanation:
Other Options:
💡 Trick to Remember:
🐳 Containers share OS → light & fast
💻 VMs have OS → heavy & isolated
—------------------------------------------------------------------------------------------------------------------
Q9:
Consider you are a software developer working on a new application for a large corporation.
Your application is expected to run on a variety of computers with different hardware specifications and operating systems.
You must ensure compatibility and smooth operation on all these systems.
Which property of an operating system is most important for you to consider?
Options:
A. User Interface
B. Security
C. ✅ Device Management
D. Resource Allocation
✅ Correct Answer: C. Device Management
🧠 Explanation:
Other Options:
💡 Trick to Remember:
⚙️ “Different devices? → Device Management!”
It’s the OS property that makes your app run smoothly everywhere.
CODIND MCQS
Q1: The question asks which of the given list of names will be displayed as a result of the following SQL command:
SELECT emp_name FROM employees WHERE emp_name LIKE '%a%';
✅ Correct Answer: Names containing the alphabet ‘a’
Explanation:
The condition LIKE '%a%' returns all employee names that contain the letter ‘a’ anywhere in the name. The % wildcard matches any number of characters (before or after ‘a’). Example: Sara, Raj, Aman will match, but Eric, John won’t.
Important About LIKE:
💡 Trick:
% = many characters, _ = one character
“Use %a% to find anything with ‘a’ anywhere.”
Q2: Which optimization technique will improve the query performance the most? SELECT * FROM CUSTOMERS WHERE State='xyz' OR State='abc';
Options:
(a) Adding more rows to the table
(b) ✅ Creating an index on the small column
(c) Using a Foreign Key on the small column
(d) Denormalizing the table
✅ Correct Answer: (b) Creating an index on the small column
Explanation: Indexing the State column allows the database to find matching rows quickly instead of scanning the whole table, improving performance in WHERE queries.
Extra Concept – Normalization:
Normalization organizes data into smaller related tables to reduce redundancy and maintain data integrity. It ensures efficient storage and easier maintenance.
—----------------------------------------------------------------------------------------------------------------------
Q3: Which SQL statement is used to display records in ascending order from a table?
Options:
(a) Select * from [table] order by [col];
(b) Select * from [table] sort by [col] ASC;
(c) ✅ Select * from [table] order by [col] ASC;
(d) Select * from [table] group by [tbl] ASC;
✅ Correct Answer: (c) Select * from [table] order by [col] ASC;
Explanation:
Example:
SELECT * FROM employees ORDER BY salary ASC;
Other Options:
(a) order by [col] works too (ASC is optional) but option (c) explicitly states ascending order, which matches the question.
(b) sort by is invalid syntax in SQL.
(d) group by is used for aggregating data, not for sorting.
💡 Trick:
“Sorting in SQL → always use ORDER BY (ASC for low→high, DESC for high→low).” —(SQL me SORT BY nahi hota.)
—----------------------------------------------
Q4:
Assume Dustin is using a browser that does not support the <video> element and wants to create a video element with a source, controls, and a fallback message.
Which option denotes the correct HTML code Dustin can use for this purpose?
Options:
A.
<video src="video.mp4" type="video/mp4" controls>
<p>Sorry, your browser doesn't support the video element.</p>
</video>
B. ✅
<video controls>
<source src="video.mp4" type="video/mp4">
<p>Sorry, your browser doesn't support the video element.</p>
</video>
C.
<video>
<source src="video.mp4" type="video/mp4" controls>
<p>Sorry, your browser doesn't support the video element.</p>
</video>
D.
<video src="video.mp4" controls>
Sorry, your browser doesn't support the video element.
</video>
✅ Correct Answer: (B)
Explanation:
Option B correctly follows the standard structure of the HTML <video> tag:
Why others are wrong:
💡 Trick:
Always write →
<video controls>
→ <source src="..." type="...">
→ fallback message inside.
—-----------------------------------------------------------
Q5:
What will be the output of the given code?
var my_arr = [3, 16, 2, 18];
function myFunction(elem) {
return (elem + 5);
}
document.write(my_arr.map(myFunction));
Options:
A. 3,16,2,18
B. ✅ 8,21,7,23
C. True
D. False
✅ Correct Answer: (B) 8,21,7,23
🧠 Explanation:
➡ Calculation:
Final Output: [8, 21, 7, 23]
💡 Notes for Revision:
Q7:
Assume a retail company notices that queries to search for customers by Email are running very slowly because the Customers table has over 5 million rows.
The query is:
SELECT * FROM Customers WHERE Email = "abc@example.com";
Which optimization technique will improve the query performance the most?
Options:
A. Adding more rows to the table
B. ✅ Creating an index on the Email column
C. Using a Foreign Key on the Email column
D. Denormalizing the table
✅ Correct Answer: (B) Creating an index on the Email column
🧠 Explanation:
Other Options:
—----------------------------------------------------------------------------------------------------------------------
Q8:
What will be the output of the depicted code?
class Test {
public int x = 45;
public int y;
public double z;
public void F1(int a) {
y = a;
}
public double F2() {
return 5;
}
public static void main(String args[]) {
Test t = new Test();
t.x = 9;
t.y = 18;
t.z = 3;
t.F1(21);
System.out.println(t.F2());
}
}
Options:
A. 9
B. 21
C. ✅ 5.0
D. Compilation Error
✅ Correct Answer: (C) 5.0
🧠 Explanation:
💡 Concept Recap:
✅ Output:
5.0
Q9:
Which of the following statements will you use to retrieve items in ascending order from a table in SQL?
Options:
A. SELECT * FROM [table] ORDER BY [tbl_clm];
B. SELECT * FROM [table] SORT BY [tbl_clm];
C. ✅ SELECT * FROM [table] ORDER BY [tbl_clm] ASC;
D. SELECT * FROM [table] GROUP BY [tbl_clm] ASC;
✅ Correct Answer: (C) SELECT * FROM [table] ORDER BY [tbl_clm] ASC;
—------------------------------------------------------------------
Q10:
What is the final value of total after executing the following pseudocode?
FUNCTION incrementByThree(n)
RETURN n + 3
END FUNCTION
total = 0
FOR i = 1 TO 3
total = total + incrementByThree(i)
END FOR
DISPLAY total
Options:
A. 7
B. 10
C. 15
D. 18
✅ Correct Answer: C. 15
🧠 Explanation (Step-by-step):
Loop runs i = 1 to 3, so three iterations.
i | incrementByThree(i) | total after addition |
1 | 1 + 3 = 4 | 0 + 4 = 4 |
2 | 2 + 3 = 5 | 4 + 5 = 9 |
3 | 3 + 3 = 6 | 9 + 6 = 15 |
— the total is 15.
—---------------------------------------------------------------------
Q11:
What does the following line in the given <canvas> tag indicate?
<canvas id="myCanvas">
HTML5 Canvas not supported.
</canvas>
Options:
A. A content for the server
B. ✅ A comment for incompatible browsers
C. A comment for Internet Explorer and Opera
D. All of the given options
✅ Correct Answer: B. A comment for incompatible browsers
🧠 Explanation:
Example:
If a browser supports <canvas>, it shows the drawing area.
If it doesn’t, it will show:
👉 “HTML5 Canvas not supported.”
Other Options:
💡 Trick to Remember:
🧩 Canvas inner text = Fallback Message
If the browser can’t draw, it shows the text instead!
—------------------------------------------------------------
Q12:
Write an SQL query to display:
The ID, Name, Department name, and Basic salary of employees working in the ‘HR’ department.
Your output should have 4 columns:
EMPID, EMPNAME, DEPTNAME, BASIC.
EMPID | EMPNAME | DEPTNAME | BASIC |
101 | Rahul | HR | 30000 |
102 | Sneha | IT | 40000 |
103 | Aman | HR | 32000 |
104 | Priya | Finance | 35000 |
SELECT EMPID, EMPNAME, DEPTNAME, BASIC
FROM EMPLOYEE
WHERE DEPTNAME = 'HR';
EMPID | EMPNAME | DEPTNAME | BASIC |
101 | Rahul | HR | 30000 |
103 | Aman | HR | 32000 |
Explanation:
—--------------------------------------------------------
Q:
Write an SQL query to display the ID, Name, Department name, and Basic salary of employees working in the ‘HR’ department.
Your output should have these 4 columns:
EMPID, EMPNAME, DEPTNAME, BASIC.
EMP ID | Emo_name | dept_ID | Basic |
101 | Rahul | D01 | 650 |
102 | Rishuv | D03 | 055 |
103 | piyush | D04 | 466 |
Dept_ID | Dept_Name |
D001 | HR |
D002 | Finance |
D03 | Tech |
SELECT
E.EMPID,
E.EMPNAME,
D.DEPTNAME,
E.BASIC
FROM
EMPLOYEE E
INNER JOIN
DEPARTMENT D ON E.DEPTID = D.DEPTID
WHERE
D.DEPTNAME = 'HR';
EMPID | EMPNAME | DEPTNAME | BASIC |
101 | Rahul | HR | 30000 |
103 | Aman | HR | 32000 |
JOIN Type | What it Returns | Example Use |
INNER JOIN | Only rows present in both tables | ✅ Used here – shows only employees with valid department (HR) |
LEFT JOIN | All rows from left (EMPLOYEE), even if no match in DEPARTMENT | Used when you want all employees, even without departments |
RIGHT JOIN | All rows from right (DEPARTMENT), even if no employees in it | Used when you want all departments, even empty ones |
🔹 INNER JOIN → Intersection → “Only common data.”
🔹 LEFT JOIN → All from left, plus matches.
🔹 RIGHT JOIN → All from right, plus matches.
—-----------------------------------------------------
A trigger in SQL is like an automatic action that runs when something happens in a table.
That “something” = INSERT, UPDATE, or DELETE.
📍 Think of it like:
“Whenever someone deletes an employee, automatically write that info somewhere else.”
CREATE TRIGGER trigger_name
{BEFORE | AFTER} {INSERT | UPDATE | DELETE}
ON table_name
FOR EACH ROW
BEGIN
-- code to execute
END;
So:
Requirement:
When a row is deleted from Employees, make a log in AuditLog.
✅ Correct trigger:
CREATE TRIGGER after_employee_delete
AFTER DELETE ON Employees
FOR EACH ROW
INSERT INTO AuditLog (EmpID, DeletedOn)
VALUES (OLD.EMPID, NOW());
Keyword | Used In | Refers To |
NEW | INSERT or UPDATE | The new data being added/modified |
OLD | DELETE or UPDATE | The existing (old) data before change |
💡 Trick to remember:
👉 DELETE → record gone → use OLD
👉 INSERT → new record → use NEW
Situation | Trigger Type | Keyword |
When data is added | AFTER INSERT | NEW |
When data is modified | AFTER UPDATE | OLD + NEW |
When data is deleted | AFTER DELETE | OLD |
“AFTER DELETE → OLD record ko yaad karo (log karo)” 😄
“BEFORE INSERT → NEW record ko check karo (validate karo)”
Question 11:
Consider that a company wants an automatic log whenever an employee record is deleted.
The schema is:
CREATE TABLE Employees (
EMPID INT PRIMARY KEY,
Name VARCHAR(50)
);
CREATE TABLE AuditLog (
LogID INT PRIMARY KEY AUTO_INCREMENT,
EmpID INT,
DeletedOn DATETIME
);
CREATE TRIGGER after_employee_delete
AFTER DELETE ON Employees
FOR EACH ROW
INSERT INTO AuditLog (EmpID, DeletedOn)
VALUES (OLD.EMPID, NOW());
🧩 Think “AFTER DELETE → OLD is gone”
→ Because the record is deleted, use OLD (not NEW).
💡 AFTER = OLD | BEFORE = NEW
—----------------------------------------------------------------
What will be the output of the following pseudo code?
1 Integer p,q,r
2 Set p = 1, q = 8, r = 9
3 q = (11 + 9) & q
4 p = q + q
5 Print p + q + r
1️⃣ Start values:
p = 1, q = 8, r = 9
2️⃣ Line 3 → q = (11 + 9) & q
20 = 10100
8 = 01000
-------------
AND=00000 → 0 ✅
✅ q = 0
3️⃣ Line 4 → p = q + q
→ p = 0 + 0 = 0
4️⃣ Line 5 → Print p + q + r
→ 0 + 0 + 9 = 9 ✅
Symbol | Mental Phrase | Shortcut |
& | both 1 | Smaller / 0 |
` | ` | any 1 |
^ | different 1 | Toggle bits |
<< | left double | ×2^n |
>> | right half | ÷2^n |
💡 Trick to Solve Without Paper (Mental Flow):
🧩 Convert each number to nearest power of 2 →
🧩 For &, take common part.
🧩 For |, take combined part.
🧩 For ^, take unique bits.
🧩 For << or >>, multiply/divide by 2.
—---------------------------------------------------------------------------------------------------------------
Question 13:
Which of the following codes is appropriate for autoplay?
(a)
<audio autoplay>
<source src="test.mp3">
<source src="test.ogg">
</audio>
(b)
<audio autoplay>
<source src="test.mp3's">
<source src="test.ogg">
</audio autoplay>
(c)
<audioplay>
<source src="test.mp3">
<source src="test.ogg">
</audioplay>
(d)
<audio>
<controls>
<source src="test.mp3">
<source src="test.ogg">
</controls>
</audio>
<audio autoplay>
<source src="test.mp3">
<source src="test.ogg">
</audio>
🧠 Auto = Start automatically!
Whenever you see <audio autoplay> or <video autoplay>,
think — “Play without pressing play!” ▶️
—---------------------------------------------------------------------
Coding Questions
Question Statement:
Given a string S, count the frequency of each character. For each character, use the largest even number less than or equal to its frequency (if it appears 5 times, use 4). Find the character with the highest such even count, and the character with the lowest odd count (odd frequencies only). Return the difference: (max even count) - (min odd count).
Example 1:
Input: aarthu
Output: 1
Example 2:
Input: aniarnkabuhaywa
Output: 3
Code
import java.util.*;
public class UserMainCode {
public int fruitfrequency(String input) {
Map<Character, Integer> freq = new HashMap<>();
for (char c : input.toCharArray()) {
freq.put(c, freq.getOrDefault(c, 0) + 1);
}
int maxEven = 0;
int minOdd = Integer.MAX_VALUE;
for (int count : freq.values()) {
int evenVal = count - (count % 2);
if (evenVal > maxEven) maxEven = evenVal;
if (count % 2 == 1 && count < minOdd) minOdd = count;
}
return maxEven - minOdd;
}
}----------------------------------------------------------
import java.util.*;
➡ Imports HashMap and other collection classes from java.util package.
public class UserMainCode {
➡ Class ka naam (Accenture exam me fixed hota hai).
public int fruitfrequency(String input) {
➡ Function jo ek String input lega aur int result (difference) return karega.
Map<Character, Integer> freq = new HashMap<>();
➡ HashMap banaya har character ka frequency (count) store karne ke liye.
Key → character, Value → us character ki frequency.
for (char c : input.toCharArray()) {
freq.put(c, freq.getOrDefault(c, 0) + 1);
}
➡ String ke har character par loop chala.
toCharArray() → string ko char array me convert karta hai.
getOrDefault(c, 0) → agar char pehli baar aa raha hai to 0 lo.
+1 → count badha ke map me store karo.
👉 Result: Map me sabhi characters ke frequency aa gaye.
int maxEven = 0;
int minOdd = Integer.MAX_VALUE;
➡ Dono variable comparison ke liye:
for (int count : freq.values()) {
➡ Map ke har frequency value par loop.
int evenVal = count - (count % 2);
➡ Agar frequency odd hai to usse nearest chhote even number me convert karo.
(Example: 5 → 4, 3 → 2, 4 → 4)
if (evenVal > maxEven) maxEven = evenVal;
➡ Sabse bada even frequency store karo.
if (count % 2 == 1 && count < minOdd) minOdd = count;
➡ Agar frequency odd hai aur ab tak mile sabse chhoti odd se chhoti hai → update minOdd.
return maxEven - minOdd;
➡ Final answer = largest even frequency − smallest odd frequency.
Input → "aarthu"
freq = {a=2, r=1, t=1, h=1, u=1}
maxEven = 2 (a=2)
minOdd = 1 (r,t,h,u all 1)
✅ Output → 2 - 1 = 1
—------------------------------------------------------------
Now asks:
Return absolute difference between (max odd frequency) and (min even frequency).
So logic is same, just reversed roles:
Earlier → biggest even − smallest odd
Now → biggest odd − smallest even (and take absolute value)
code==
import java.util.*;
public class Avi {
public int fun1(String input) {
Map<Character, Integer> freq = new HashMap<>();
// Count frequency of each character
for (int i = 0; i < input.length(); i++) {
char c = input.charAt(i);
freq.put(c, freq.getOrDefault(c, 0) + 1);
}
int minEven = Integer.MAX_VALUE;
int maxOdd = 0;
// Check frequencies
for (int count : freq.values()) {
if (count % 2 == 0 && count < minEven)
minEven = count;
if (count % 2 == 1 && count > maxOdd)
maxOdd = count;
}
return Math.abs(maxOdd - minEven);
}
public static void main(String[] args) {
Avi obj = new Avi();
System.out.println(obj.fun1("aarthu")); // Output: 1
}
}
—-------------------------------------------------------------------------------------------------------------------------
Frontend
<!DOCTYPE html>
<html>
<head>
<title>My Page</title>
</head>
<body>
<h1>Hello!</h1>
</body>
</html>
💡 Meaning:
Tag | Purpose | Example |
<h1>–<h6> | Headings | <h2>Welcome</h2> |
<p> | Paragraph | <p>Hello world!</p> |
<img> | Image | <img src="cat.jpg" alt="Cat"> |
<a> | Link | <a href="https://google.com">Google</a> |
<button> | Button | <button>Click</button> |
<input> | Input field | <input type="text"> |
<div> | Block container | <div class="box"></div> |
Attribute | Use | Example | In CSS | In JS |
id | unique (1 element) | <div id="main"></div> | #main | document.getElementById("main") |
class | shared (many elements) | <div class="box"></div> | .box | document.getElementsByClassName("box") |
🧠 Trick:
➡️ ID = Individual
➡️ CLASS = Common
.box {
width: 100px;
height: 100px;
background-color: yellow;
border: 2px solid red;
}
Property | Example | Meaning |
color | color: red; | Text color |
background-color | background-color: yellow; | Background |
border | border: 2px solid black; | Border around element |
width, height | width:100px; height:50px; | Size |
margin, padding | margin:10px; padding:5px; | Spacing |
<button onclick="sayHi()">Click Me</button>
<script>
function sayHi() {
alert("Hello from JavaScript!");
}
</script>
🧠 Trick → "onclick" calls function on click.
<input id="user" type="text" placeholder="Enter name">
<button onclick="showName()">Show</button>
<p id="result"></p>
<script>
function showName() {
let name = document.getElementById("user").value;
document.getElementById("result").innerText = "Hello, " + name + "!";
}
</script>
<p id="text">Change my color</p>
<button onclick="changeColor()">Click</button>
<script>
function changeColor() {
document.getElementById("text").style.color = "blue";
}
</script>
<img id="photo" src="cat.jpg" width="100">
<style>
.green-border { border: 3px solid green; }
</style>
<script>
document.getElementById("photo").onclick = function() {
this.classList.add("green-border");
};
</script>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<button id="btn">Click</button>
<script>
$("#btn").click(function(){
alert("Hello from jQuery!");
});
</script>
<input id="name" type="text" placeholder="Enter name">
<button id="show">Show</button>
<p id="msg"></p>
<script>
$("#show").click(function(){
let val = $("#name").val();
$("#msg").text("Welcome " + val);
});
</script>
<p id="p1">Click to turn Red</p>
<button id="btn">Click</button>
<script>
$("#btn").click(function(){
$("#p1").css("color", "red");
});
</script>
<img src="cat.jpg" id="img1" class="animal">
<style>
.animal { width: 100px; height: 100px; }
.green-border { border: 3px solid green; }
</style>
<script>
$(".animal").click(function(){
$(this).addClass("green-border");
});
</script>
Task | Pure JS | jQuery |
Select by ID | document.getElementById("id") | $("#id") |
Select by Class | document.getElementsByClassName("class") | $(".class") |
Change Text | el.innerText = "Hi" | $("#id").text("Hi") |
Get Value | el.value | $("#id").val() |
Add Class | el.classList.add("a") | $("#id").addClass("a") |
Change CSS | el.style.color="red" | $("#id").css("color","red") |
Click Event | el.onclick = f | $("#id").click(f) |
✅ Q1: Add a green border when image is clicked → (use JS or jQuery)
✅ Q2: Take input from text box, show message → Hello + name
✅ Q3: Change color of paragraph when button is clicked.
✅ Q4: Print alert box message “Form submitted!” when button clicked.
✅ Q5: Hide or show element when clicked using .hide() or .show() (jQuery).
✅ Q6: Apply CSS dynamically on click (e.g., increase font size).
Concept | Shortcut Line |
#id | 1 element (Unique → Individual) |
.class | Many elements (Common → Group) |
onclick | Call function on click |
alert() | Show popup |
innerText | Change visible text |
style.property | Change CSS via JS |
addClass() | Add CSS class via jQuery |
val() | Get or set input value |
text() | Change text content |
css() | Change style property dynamically |
—----------------------------------------------------------------------------------------------------------------------------
Objective(s):
Using HTML, CSS, and JavaScript, you need to complete the following tasks:
Constraint(s):
Given HTML structure:
<div class="animal-container">
<p>Tiger</p>
</div>
<div class="animal-container">
<p>Lion</p>
</div>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Animal Images</title>
<style>
.animal-image {
width: 100px;
height: 100px;
margin: 10px;
}
.green-border {
border: 3px solid green;
}
</style>
<!-- jQuery CDN (must not remove) -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>
<section id="animals">
<div class="animal-container">
<img src="https://mettl.com/uploads/482135/8e9c5fe8-bd43-4a4d-9776-839b3a6abff6.jpg"
id="tiger-image" class="animal-image" alt="Tiger">
<p>Tiger</p>
</div>
<div class="animal-container">
<img src="https://mettl.com/uploads/482135/6c4199e6-6e74-4af6-bc74306c3aba036d.jpg"
id="lion-image" class="animal-image" alt="Lion">
<p>Lion</p>
</div>
</section>
<script>
$(".animal-image").click(function() {
$(this).addClass("green-border");
});
</script>
</body>
</html>
.--------------------------------------------------------------------------------------------------------------
You want to create a block that changes its shape to a circular block when you move your mouse over it, and reverts back to a rectangular block when you move your mouse away from it, with a slow-fast-slow animation speed.
How will you achieve this goal?
(a)
.rect:hover {
border-radius: 20px;
transition: 0.5s;
}
(b)
.rect:hover {
border-radius: 30px;
transition: 0.5s;
}
(c)
.rect:hover {
border-radius: 40px;
transition: 0.5s;
}
(d)
.rect:hover {
border-radius: 58px;
transition: 0.5s;
}
.rect:hover {
border-radius: 58px;
transition: 0.5s;
}
“Circle on hover → border-radius 50% or max px + transition.”
Small values (20, 30, 40px) → just rounded rectangle ❌
Large value (≈50–60px or 50%) → perfect circle ✅
You can also write smooth animation like this:
transition: all 0.5s ease-in-out;
👉 gives that slow-fast-slow smooth effect automatically.
Would you like me to add one visual comparison table (square → rounded → circle) below this for your notes? It’s very useful for quick recall before exams.
Objective(s):
Using HTML, CSS, and JavaScript, you need to complete the following tasks:
Constraint(s):
Given HTML structure:
<div class="animal-container">
<p>Tiger</p>
</div>
<div class="animal-container">
<p>Lion</p>
</div>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Animal Images</title>
<style>
.animal-image {
width: 100px;
height: 100px;
margin: 10px;
}
.green-border {
border: 3px solid green;
}
</style>
<!-- jQuery CDN (must not remove) -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>
<section id="animals">
<div class="animal-container">
<img src="https://mettl.com/uploads/482135/8e9c5fe8-bd43-4a4d-9776-839b3a6abff6.jpg"
id="tiger-image" class="animal-image" alt="Tiger">
<p>Tiger</p>
</div>
<div class="animal-container">
<img src="https://mettl.com/uploads/482135/6c4199e6-6e74-4af6-bc74306c3aba036d.jpg"
id="lion-image" class="animal-image" alt="Lion">
<p>Lion</p>
</div>
</section>
<script>
$(".animal-image").click(function() {
$(this).addClass("green-border");
});
</script>
</body>
</html>
Step | Description | Reason |
<img> tags added | Show Tiger & Lion images | Each has src, id, and class |
.animal-image class | Common style (100×100) | Same dimensions for both |
.green-border class | Border style | Added dynamically on click |
jQuery click function | Detects when an image is clicked | Adds border class instantly |
CDN link | https://code.jquery.com/jquery-3.6.0.min.js | Required for $() to work |
In the given code, when is myFunction() called?
<html>
<head>
<script language="JavaScript">
function myFunction() {
alert("My Function is called");
}
</script>
</head>
<body>
<img src="http://www.example.com/mylogo.png" onabort="myFunction()">
</body>
</html>
(a) When the page is closed
(b) When the page is loaded
(c) ✅ When the user presses Esc before the page loads (or image fails to load)
(d) When the page is refreshed
(c) When the user presses Esc before the page loads (or when image loading is stopped)
🧠 “Abort = Stop before done” → Like pressing Esc or cancelling download halfway!
👉 Keyword Trick:
Abort = Stop loading halfway
Error = Couldn’t load at all
Load = Successfully loaded
Event | When It Fires | Example | Trick |
onload | When page or image finishes loading | <body onload="ready()"> | ✅ Load Done |
onerror | When image/file fails to load | <img onerror="fix()"> | ❌ Error Found |
onabort | When loading is stopped mid-way | <img onabort="stop()"> | ⛔ Stopped Loading |
onunload | When user leaves page/tab | <body onunload="bye()"> | 🚪 Leaving Page |
You can define and connect functions to these events like this:
<body onload="pageReady()" onunload="saveData()">
<img src="lion.jpg" onerror="imgError()" onabort="imgStopped()">
<script>
function pageReady() { alert("Page loaded!"); }
function imgError() { alert("Image failed to load!"); }
function imgStopped() { alert("Image load stopped!"); }
function saveData() { alert("Page closed, data saved!"); }
</script>
</body>
“Load → Done ✅, Error → Gone ❌, Abort → Stopped ⛔, Unload → Move On 🚪”
—---------------------------------------------------------------------------------------------------------------
OOPS
👉 Object-Oriented Programming System (OOPS) = Programming style where everything is treated as an object.
💡 Object = real-world entity (Car, Student, Employee)
💡 Class = blueprint / template to create objects
Concept | Meaning | Trick Line |
Encapsulation | Binding data & methods in a single unit (class) | “Capsule of data + functions” |
Abstraction | Hiding internal details & showing only necessary part | “TV remote — use button, not circuit” |
Inheritance | Reusing parent features in child | “Child inherits traits of parent” |
Polymorphism | Same name, many forms | “One word, different meanings” |
✅ Definition: Wrapping data (variables) and code (methods) into one single unit — the class.
✅ Goal: Protect data from outside access.
✅ Achieved using: private variables + public getters & setters.
class Student {
private int age;
public void setAge(int a) { age = a; }
public int getAge() { return age; }
}
🧠 Trick: “Encapsulation = Data hiding by using private + getters/setters.”
✅ Definition: Hiding complex implementation and showing only required info.
✅ Achieved by: abstract classes or interfaces.
abstract class Car {
abstract void start();
}
class BMW extends Car {
void start() { System.out.println("BMW starts with push button"); }
}
🧠 Trick: “Abstraction = Hide internal, show essential.”
✅ Definition: Acquiring properties and methods of another class.
✅ Achieved using: extends keyword.
class Parent {
void show() { System.out.println("Parent class"); }
}
class Child extends Parent {
void display() { System.out.println("Child class"); }
}
🧠 Trick:
“Inherit = reuse parent code.”
Parent → Child = IS-A relationship (Child is a Parent type).
Type | Example |
Single | One parent → One child |
Multilevel | Parent → Child → Grandchild |
Hierarchical | One parent → multiple children |
Multiple (Not directly in Java) | Done via Interface |
🧠 Trick Line:
“Single road, Multi floors, One root many branches, Interface = Mix roads.”
✅ Meaning: “Many forms” → Same method behaves differently depending on context.
✅ Two types:
Type | When decided | Example | Also called |
Compile-time Polymorphism | At compile time | Method Overloading | Static / Early Binding |
Runtime Polymorphism | At runtime | Method Overriding | Dynamic / Late Binding |
Concept: Same method name but different parameters (number/type/order).
class Calculator {
int add(int a, int b) { return a + b; }
double add(double a, double b) { return a + b; }
}
🧠 Trick:
“Overloading = Same name, diff arguments, same class.”
Compiler decides which method to run → early binding.
Concept: Same method name and parameters, but redefined in child class.
class Animal {
void sound() { System.out.println("Animal sound"); }
}
class Dog extends Animal {
void sound() { System.out.println("Dog barks"); }
}
Animal a = new Dog();
a.sound();
✅ Output: Dog barks
🧠 Trick:
“Overriding = Child Overrules Parent.”
Runtime polymorphism = Dynamic binding
Binding | Decided When | Example | Type |
Early Binding | Compile-time | Overloading | Static |
Late Binding | Runtime | Overriding | Dynamic |
🧠 Trick:
“Early → Easy (compile time)”
“Late → Let’s see later (runtime)”
Concept | Happens In | When Decided | Called As |
Overloading | Same class | Compile time | Static / Early |
Overriding | Parent-child | Runtime | Dynamic / Late |
Modifier | Access Scope | Notes |
private | Within class | Used for encapsulation |
default | Same package | No keyword |
protected | Same package + child in other package | Used in inheritance |
public | Anywhere | Global access |
🧠 Trick:
“private < default < protected < public” (small → big scope)
✅ Used to initialize objects automatically.
class Demo {
int x;
Demo(int val) { x = val; }
}
🧠 Trick: “Constructor = First function called automatically.”
Keyword | Meaning | Example |
final | Cannot be changed/overridden | final int a=5; |
static | Belongs to class, not object | static int count; |
super | Access parent’s method/constructor | super.show(); |
this | Refers to current object | this.a = a; |
🧠 Trick:
super = parent, this = current, static = common, final = fixed.
Feature | Abstract Class | Interface |
Methods | Can have both abstract & concrete | All methods abstract (till Java 7) |
Variables | Can have instance vars | All are public static final |
Inheritance | extends | implements |
Multiple inheritance | ❌ Not allowed | ✅ Allowed |
🧠 Trick:
“Abstract = partial design”
“Interface = full rule book”
Concept | Example |
Encapsulation | Bank account with private balance |
Abstraction | ATM machine (you don’t see backend) |
Inheritance | Father → Son |
Polymorphism | One word “run” = run() in diff classes |
class A {
void show() { System.out.println("A"); }
}
class B extends A {
void show() { System.out.println("B"); }
}
class Test {
public static void main(String[] args) {
A obj = new B();
obj.show();
}
}
✅ Output: B
👉 Because of runtime polymorphism (Overriding + Late binding)
Concept | Shortcut |
Overloading | Same name, diff args → compile-time |
Overriding | Same name, same args → runtime |
Encapsulation | Private + getters/setters |
Abstraction | Hide details using abstract/interface |
Inheritance | Parent-child → reuse |
Polymorphism | One name, many forms |
Early Binding | Overloading |
Late Binding | Overriding |
super | Parent call |
this | Current object |
final | Cannot override/change |
========================================================================
Question 1:
Consider the given code — what will be the output?
Analyze the options carefully and select the correct answer.
class Children {
private final void flipper() {
System.out.println("Children");
}
}
public class Parent extends Children {
public final void flipper() {
System.out.println("Parent");
}
public static void main(String[] args) {
new Parent().flipper();
}
}
A. Children
B. Parent
C. Parent Children
D. Compilation Error
B. Parent
💬 Output:
Parent
Overloading = Same name, different parameters, same class → Compile-time
Overriding = Same name, same parameters, different class (parent-child) → Runtime
—-------------------------------------------------------------------------------------------------------------------------
Assume that a Java application has a class TeaMac that can handle different types of tea. The class has a method to boil tea based on the selected type. A code snippet is shown below:
public class TeaMac {
public Coffee boilTea(ChooseTea choosed) {
switch (choosed) {
case GREEN_TEA:
return boilGreenTea();
default:
// default code
}
}
public List boilTea(ChooseTea choosed) {
List tea= new ArrayList(number);
for (int i = 0; i < number; i++) {
teas.add(boilTea(choosed));
}
return teas;
}
}
(a) Static polymorphism
(b) Dynamic polymorphism
(c) Late binding
(d) Method overriding
💬 “Overloading happens in one class, Overriding needs two classes.”
💬 “Static = Same class, Dynamic = Derived class.
—----------------------------------------------------------------------------------------------------------
Consider the given code. What will be the output of the code?
class Children {
private final void flipper() {
System.out.println("Children");
}
}
public class Parent extends Children {
public final void flipper() {
System.out.println("Parent");
}
public static void main(String[] args) {
new Parent().flipper();
}
}
(a) Children
(b) ✅ Parent
(c) Children Parent
(d) Parent Children
👉 Parent
In main(),
new Parent().flipper();
Concept | Keyword | Meaning |
private | Not inherited | Child can’t access it |
final | Cannot be overridden | Prevents polymorphic change |
extends | Inheritance | But here, no override happened |
Method hiding | Occurs with static, not with private | So here → independent method |
🧩 “Private = invisible, Final = fixed.”
So, Parent’s flipper() doesn’t override — it creates a new one.
Therefore, output → Parent.
—------------------------------------------------------------------------------------------------------------
✅ Question4):
Which of the following statements is true considering the code below?
class Employee extends Person {
Address address;
}
A. Employee has is-A relationship with Person and has-A relationship with Address.
B. Employee has is-A relationship with Address and has-A relationship with Person.
C. Employee has is-A relationship with Person and Address.
D. Employee has has-A relationship with Address and Person.
A. Employee has is-A relationship with Person and has-A relationship with Address.
👉 “extends = is-A,
inside object = has-A**”
—-----------------------------------------------------------------------------------------------------------------