Phone: +255 692 127 931

Thursday, July 17, 2025

System Developer Questions and Answers



 System Developer

QUESTION NO 1.

🔧 Tools & Definitions

  1. **What does "CI" stand for in DevOps?**
    A) Continuous Inspection
    B) Continuous Integration

    C) Continuous Improvement
    D) Continuous Implementation
    Answer: B
  2. What does "CD" commonly stand for?
    A) Continuous Development
    B) Continuous Deployment or Delivery

    C) Code Deployment
    D) Code Delivery
  3. Which tool is an open-source automation server written in Java?
    A) CircleCI
    B) GitLab CI
    C) Jenkins
     
  4. Which cloud-native CI/CD tool was developed by Thought Works and renamed in 2010?
    A) Travis CI
    B) GoCD
     
    C) Bamboo
    D) TeamCity

📦 Version Control & Pipelines

  1. Which VCS is most popular in CI/CD pipelines?
    A) SVN
    B) Mercurial
    C) Git
  2. What file format is typically used for "Pipeline as Code"?
    A) JSON
    B) YAML
     
    C) XML
    D) INI
  3. Which tool integrates with GitLab repository for CI/CD?
    A) Jenkins
    B) GitLab CI
     

C) CircleCI
D) Travis CI


🛠️ Build & Deployment Strategies

  1. **What is the primary role of a build server? **
    A) Deploy code to production
    B) Monitor application metrics
    C) Compile code & run tests

    D) Manage infrastructure
  2. What describes a deployment to a small group before full release?
    A) Blue-Green Deployment
    B) Canary Deployment
  3. **Blue-Green Deployment entails: **
    A) Always using containers
    B) Two identical environments with traffic swap

    C) Rolling update to all servers
    D) Manual rollback only

🧪 Testing & Quality

  1. **Continuous Testing means: **
    A) Manual QA after builds
    B) Running automated tests at every stage

    C) Only unit tests
    D) Testing only in production
  2. A "smoke test" is:
    A) Full performance test
    B) Basic functional check post-build

    C) Security scan
    D) Load test
  3. Containers offer this key benefit:
    A) Vendor lock-in
    B) Consistent environments

    C) Larger size
    D) Slower execution

🛠️ Popular CI/CD Tools

  1. Which tool is used for container orchestration in CI/CD?
    A) Ansible
    B) Kubernetes
     
  2. Which tool helps provision infrastructure as code (IaC)?
    A) Jenkins
    B) Docker
    C) Terraform
     
  3. Which tool is an Atlassian CI/CD solution?
    A) TeamCity
    B) Bamboo
  4. Which tool offers a cloud-based CI/CD with YAML config?
    A) Semaphore

    B) GoCD
    C) Jenkins
    D) Bamboo
  5. Which one is not a CI/CD tool?
    A) Jenkins
    B) CircleCI
    C) Maven
     
  6. D) GitHub Actions

⚙️ Practices & Monitoring

  1. **What does "shift-left testing" mean? **
    A) Test after deployment
    B) Test earlier in lifecycle
     

C) No test environment
D) Only manual testing

  1. Which tool is for visualizing time-series data in CI/CD monitoring?
    A) Ansible
    B) Grafana
     
  2. C) Puppet
    D) Git

QUESTION NO 2

Microservices Concepts in Kubernetes

  1. In Kubernetes, each microservice is typically deployed in a:
    A) Node
    B) Pod

    C) Namespace
    D) Volume
  2. What Kubernetes object manages the desired number of pod replicas for a microservice?
    A) ConfigMap
    B) Deployment

    C) Service
    D) DaemonSet
  3. How does Kubernetes enable service discovery for microservices?
    A) Through DNS-based service naming

    B) By using IP addresses
    C) Manual configuration
    D) By updating
    /etc/hosts
  4. Which Kubernetes resource is used to expose a microservice internally within the cluster?
    A) Ingress
    B) NodePort
    C) ClusterIP

    D) LoadBalancer
  5. What does a Service object in Kubernetes abstract?
    A) Network file system
    B) IP address management
    C) Logical set of pods and access policy

    D) Volume mounting

Deployment and Scaling

  1. Which of the following manages rolling updates of microservices in Kubernetes?
    A) StatefulSet
    B) Deployment

    C) ReplicaSet
    D) Pod
  2. Which Kubernetes controller should be used for stateful microservices (e.g., databases)?
    A) Deployment
    B) DaemonSet
    C) StatefulSet

    D) Job
  3. What is the purpose of Horizontal Pod Autoscaler (HPA)?
    A) Allocate storage
    B) Scale pods based on CPU/memory usage

    C) Deploy containers
    D) Configure namespaces
  4. Which command scales a deployment to 10 replicas?
    A)
    kubectl autoscale deployment my-app
    B)
    kubectl scale deployment my-app --replicas=10
    C)
    kubectl update pods --replicas=10
    D)
    kubectl update deployment --size=10
  5. How can Kubernetes ensure high availability of microservices?
    A) By using one large pod
    B) With multiple replicas across nodes

    C) By creating a single master node
    D) By running services without pods

Networking & Routing

  1. Which Kubernetes object routes external HTTP traffic to microservices?
    A) NodePort
    B) Ingress

    C) Service
    D) PersistentVolume
  2. Which is the default service type in Kubernetes?
    A) LoadBalancer
    B) NodePort
    C) ClusterIP

    D) ExternalName
  3. How does Kubernetes Ingress support multiple microservices?
    A) Using IP whitelisting
    B) By load balancing TCP only
    C) With URL-based routing

    D) Through service chaining
  4. What does kube-proxy do in a Kubernetes cluster?
    A) Exposes services on the internet
    B) Monitors pod health
    C) Maintains network rules for service routing

    D) Manages deployments

 Security & Configuration

  1. Which resource is used to store non-sensitive configuration data?
    A) Secret
    B) ConfigMap

    C) Volume
    D) PersistentVolumeClaim
  2. What does a Kubernetes Secret store?
    A) Pod logs
    B) Credentials/API keys

    C) Docker images
    D) Log files
  3. How does RBAC enhance microservices security?
    A) Controls storage access
    B) Restricts pod-to-pod communication
    C) Defines fine-grained access to cluster resources

    D) Blocks ingress traffic
  4. What is the purpose of ServiceAccount in Kubernetes?
    A) Controls persistent volumes
    B) Provides identity to pods for API access

    C) Binds pods to nodes
    D) Exposes metrics

Observability & Best Practices

  1. Which tool is commonly used for monitoring microservices on Kubernetes?
    A) MongoDB
    B) Prometheus

    C) Grafana Agent
    D) Redis
  2. Which probe checks if a microservice is ready to accept traffic?
    A) Liveness probe
    B) Readiness probe

    C) Startup probe
    D) Service probe
  3. Why use namespaces for microservices?
    A) Reduce pod memory usage
    B) Provide network security
    C) Organize resources and avoid name collisions

    D) Enable persistent volumes
  4. Which of the following helps enforce policies across microservices?
    A) ReplicaSet
    B) NetworkPolicy

    C) PodDisruptionBudget
    D) DaemonSet

Advanced Practices

  1. Which tool adds service mesh functionality to Kubernetes for microservices communication?
    A) Prometheus
    B) Istio

    C) Helm
    D) Terraform
  2. How are microservices typically managed as a Helm chart?
    A) One chart per container
    B) One chart per microservice

    C) Charts are not used
    D) One chart per cluster
  3. What is a sidecar container used for in microservices?
    A) To run backup jobs
    B) To proxy communication or log traffic

    C) To scale pods
    D) To auto-restart failed pods

QUESTION NO. 3

 Kubernetes for Microservices Architecture  

Section 1: Microservices Basics

Q1. In Kubernetes, each microservice is ideally deployed in a:

·        A) Node

·        B) Pod

·        C) Namespace

·        D) Volume

Answer: B) Pod
Explanation: A Pod is the smallest deployable unit in Kubernetes and typically hosts one microservice.

Q2. What Kubernetes object manages the desired number of replicas for a microservice?

·        A) ConfigMap

·        B) Deployment

·        C) Service

·        D) DaemonSet

Answer: B) Deployment
Explanation: A Deployment ensures the correct number of Pods (replicas) are running and allows for updates and rollbacks.

Q3. How does Kubernetes handle service discovery for microservices?

·        A) Using hardcoded IPs

·        B) Through DNS-based service names

·        C) By editing hosts file

·        D) Through etcd querying

Answer: B) DNS-based service names
Explanation: Kubernetes assigns DNS names to Services that enable Pods to discover each other.

Section 2: Deployment and Scaling

Q4. Which Kubernetes resource is used to perform rolling updates of a microservice?

·        A) StatefulSet

·        B) Deployment

·        C) ReplicaSet

·        D) DaemonSet

Answer: B) Deployment
Explanation: Deployments support rolling updates and rollbacks, making them suitable for stateless microservices.

Q5. Which controller is used for microservices that need stable network identity and persistent storage?

·        A) ReplicaSet

·        B) StatefulSet

·        C) Job

·        D) DaemonSet

Answer: B) StatefulSet
Explanation: StatefulSet is best for stateful applications like databases where persistent identity is required.

Q6. How do you manually scale a deployment to 5 replicas?

·        A) kubectl scale deployment <name> --replicas=5

·        B) kubectl resize pod <name> --count=5

·        C) kubectl autoscale --replicas=5

·        D) kubectl update deployment <name>

Answer: A) kubectl scale deployment <name> --replicas=5
Explanation: This command directly sets the number of running Pods in a deployment.

Section 3: Networking & Service Discovery

Q7. What is the default service type in Kubernetes?

·        A) LoadBalancer

·        B) NodePort

·        C) ClusterIP

·        D) ExternalName

Answer: C) ClusterIP
Explanation: ClusterIP exposes the service on a cluster-internal IP. This is the default type.

Q8. Which Kubernetes resource is used to expose services externally over HTTP/HTTPS?

·        A) Service

·        B) Ingress

·        C) PersistentVolume

·        D) DaemonSet

Answer: B) Ingress
Explanation: Ingress allows routing HTTP/S traffic to Services using rules and path-based routing.

Q9. Which component manages network rules for connecting Services in Kubernetes?

·        A) kubelet

·        B) kube-proxy

·        C) scheduler

·        D) controller-manager

Answer: B) kube-proxy
Explanation: kube-proxy manages the network rules that route traffic to the correct Pods.

🔐 Section 4: Configuration & Security

Q10. What Kubernetes resource is used to store environment configurations like database URLs?

·        A) Secret

·        B) ConfigMap

·        C) PodSpec

·        D) Volume

Answer: B) ConfigMap
Explanation: ConfigMaps allow you to decouple configuration artifacts from image content.

Q11. How do Kubernetes Secrets differ from ConfigMaps?

·        A) Secrets are encrypted and used for sensitive data

·        B) Secrets are stored in local storage

·        C) Secrets can’t be used in volumes

·        D) Secrets are only for admin use

Answer: A) Secrets are encrypted and used for sensitive data
Explanation: Secrets are base64-encoded and often encrypted to store confidential information like passwords.

Q12. Which of the following is used to grant API access to Pods?

·        A) PodSecurityPolicy

·        B) NetworkPolicy

·        C) ServiceAccount

·        D) RoleBinding

Answer: C) ServiceAccount
Explanation: ServiceAccounts provide identity to Pods for accessing the Kubernetes API securely.


🚦 Section 5: Advanced Patterns


Q13. What is a sidecar container in a microservice Pod?

·        A) A backup container

·        B) A helper container that extends or enhances functionality

·        C) A monitoring dashboard

·        D) A job scheduler

Answer: B) A helper container that extends or enhances functionality
Explanation: Sidecars are used for tasks like logging, service mesh proxying, or caching.

Q14. What tool is commonly used for microservice monitoring in Kubernetes?

·        A) Ansible

·        B) Prometheus

·        C) Kafka

·        D) Redis

Answer: B) Prometheus
Explanation: Prometheus is widely used for scraping metrics and monitoring Kubernetes-based systems.

Q15. What is the benefit of using namespaces for microservices?

·        A) Increases pod performance

·        B) Allows resource and name isolation

·        C) Boosts storage

·        D) Reduces startup time

Answer: B) Allows resource and name isolation
Explanation: Namespaces logically separate applications or teams within a cluster.

 

QUESTION NO 4:

Angular Features  

 Section 1: Core Concepts

Q1. What is the primary purpose of Angular?

·        A) Backend development

·        B) Static website hosting

·        C) Building dynamic single-page applications

·        D) Styling HTML

Answer: C) Building dynamic single-page applications
Explanation: Angular is a front-end framework used to build SPA (Single-Page Applications) using TypeScript and HTML.

Q2. Which programming language is Angular primarily written in?

·        A) JavaScript

·        B) TypeScript

·        C) Python

·        D) Dart

Answer: B) TypeScript
Explanation: Angular is built with TypeScript, a superset of JavaScript that includes static typing.

Q3. What is a component in Angular?

·        A) A REST API

·        B) A database record

·        C) A building block of UI

·        D) A service worker

Answer: C) A building block of UI
Explanation: Components control a section of the UI and consist of an HTML template, a class, and metadata.

⚙️ Section 2: Angular Architecture

Q4. Which decorator is used to define a component in Angular?

·        A) @Service

·        B) @Directive

·        C) @Injectable

·        D) @Component

Answer: D) @Component
Explanation: The @Component decorator marks a class as an Angular component and provides configuration metadata.

Q5. What is the role of NgModules in Angular?

·        A) To create animations

·        B) To encapsulate a group of related components

·        C) To manage CSS styles

·        D) To write database queries

Answer: B) To encapsulate a group of related components
Explanation: NgModules group related features, components, directives, and pipes.

Q6. Which file is the root module of every Angular app?

·        A) main.ts

·        B) index.html

·        C) app.module.ts

·        D) angular.json

Answer: C) app.module.ts
Explanation: app.module.ts is the root module that bootstraps the Angular application.

🔁 Section 3: Data Binding

Q7. Which symbol is used for two-way data binding in Angular?

·        A) []

·        B) {{}}

·        C) ()

·        D) [()]

Answer: D) [()]
Explanation: The banana-in-a-box syntax [()] represents two-way binding (commonly used with ngModel).

Q8. What is interpolation in Angular?

·        A) Binding a method to an event

·        B) Repeating elements in a loop

·        C) Displaying dynamic values in HTML

·        D) Creating a new component

Answer: C) Displaying dynamic values in HTML
Explanation: Interpolation ({{ value }}) allows data from a component to be displayed in the HTML template.

Q9. Which directive is used for conditional rendering in Angular?

·        A) *ngIf

·        B) *ngFor

·        C) ngModel

·        D) ngBind

Answer: A) *ngIf
Explanation: *ngIf is a structural directive used to conditionally include/exclude an element from the DOM.

🔧 Section 4: Services & Dependency Injection

Q10. Which decorator is used to make a class available for dependency injection?

·        A) @Inject

·        B) @Service

·        C) @Injectable

·        D) @Provider

Answer: C) @Injectable
Explanation: @Injectable marks a class as available to be injected as a dependency.

Q11. Angular services are typically used to:

·        A) Store UI layout

·        B) Perform HTTP requests or business logic

·        C) Control routing

·        D) Format dates

Answer: B) Perform HTTP requests or business logic
Explanation: Services are reusable logic providers, often for data and HTTP communication.

🌐 Section 5: Routing & Navigation

Q12. Which Angular module is used for client-side routing?

·        A) FormsModule

·        B) HttpClientModule

·        C) RouterModule

·        D) BrowserModule

Answer: C) RouterModule
Explanation: RouterModule enables routing and navigation between components based on the URL.

Q13. What is the purpose of <router-outlet>?

·        A) Display event logs

·        B) Control animations

·        C) Render the matched component for the route

·        D) Output HTTP responses

Answer: C) Render the matched component for the route
Explanation: <router-outlet> is a placeholder that Angular dynamically fills based on the route.


🔐 Section 6: Forms & Validation


Q14. Which directive enables two-way binding in template-driven forms?

·        A) ngBind

·        B) ngSwitch

·        C) ngModel

·        D) ngFor

Answer: C) ngModel
Explanation: ngModel binds form inputs to component properties in both directions.


Q15. Which form type in Angular provides more control and flexibility?

·        A) Template-driven forms

·        B) Reactive forms

·        C) JSON-based forms

·        D) Inline forms

Answer: B) Reactive forms
Explanation: Reactive forms offer precise control, validation, and are built programmatically.

 

 

QUESTION NO 5.

📘 Test-Driven Development (TDD)


🧩 Section 1: Fundamentals of TDD


Q1. What is the first step in the TDD cycle?

·        A) Refactor

·        B) Write production code

·        C) Write a failing test

·        D) Deploy the application

Answer: C) Write a failing test
Explanation: TDD begins with writing a test for the functionality you’re about to implement — the test should fail initially.


Q2. What is the correct order of the TDD cycle?

·        A) Red → Refactor → Green

·        B) Green → Red → Refactor

·        C) Red → Green → Refactor

·        D) Write Code → Run Tests → Debug

Answer: C) Red → Green → Refactor
Explanation: First write a failing test (Red), then make it pass (Green), then clean up the code (Refactor).


Q3. In TDD, what does the “Red” phase represent?

·        A) A test that passed

·        B) Writing production code

·        C) A failing test

·        D) Code optimization

Answer: C) A failing test
Explanation: The "Red" phase indicates the test is failing, confirming the feature doesn't yet exist.


Q4. What is the primary goal of TDD?

·        A) Improve database queries

·        B) Ensure test coverage before coding

·        C) Reduce UI bugs

·        D) Build applications faster

Answer: B) Ensure test coverage before coding
Explanation: TDD emphasizes writing tests first to define the desired behavior of software.


Q5. Which of the following is a common benefit of TDD?

·        A) Slower development time

·        B) Less refactoring

·        C) Fewer defects in production

·        D) Reduced test coverage

Answer: C) Fewer defects in production
Explanation: TDD leads to more reliable, testable, and maintainable code.


⚙️ Section 2: TDD in Practice


Q6. Which testing level does TDD primarily focus on?

·        A) End-to-end testing

·        B) Unit testing

·        C) Load testing

·        D) Security testing

Answer: B) Unit testing
Explanation: TDD is centered around writing unit tests before developing the implementation.


Q7. In a TDD workflow, when should integration tests be written?

·        A) Before unit tests

·        B) After unit tests

·        C) Never

·        D) Along with refactoring

Answer: B) After unit tests
Explanation: Unit tests come first in TDD; integration tests are often layered on top afterward.


Q8. Which development approach is most closely aligned with TDD?

·        A) Code-first

·        B) Database-first

·        C) Design-first

·        D) Test-first

Answer: D) Test-first
Explanation: TDD follows a test-first approach, where tests are written before the implementation code.


Q9. Which assertion is true in the context of TDD?

·        A) TDD eliminates the need for QA

·        B) TDD guarantees zero bugs

·        C) TDD improves design and modularity

·        D) TDD is only for test engineers

Answer: C) TDD improves design and modularity
Explanation: Writing testable code often results in loosely coupled, well-structured modules.


Q10. What should you do if a test passes unexpectedly in TDD?

·        A) Ignore it

·        B) Refactor immediately

·        C) Check the test logic and assumptions

·        D) Proceed to next feature

Answer: C) Check the test logic and assumptions
Explanation: If a test passes before implementing the feature, the test may be incorrect or not testing what you expect.


🔍 Section 3: Tools & Best Practices


Q11. Which of these tools is commonly used for unit testing in JavaScript?

·        A) JUnit

·        B) PyTest

·        C) Mocha

·        D) TestNG

Answer: C) Mocha
Explanation: Mocha is a widely-used JavaScript test framework often used in TDD workflows.


Q12. In TDD, when should refactoring occur?

·        A) Before writing tests

·        B) After the tests fail

·        C) After the tests pass

·        D) After deployment

Answer: C) After the tests pass
Explanation: Refactor only once tests are passing, so you don't introduce errors into unverified code.


Q13. Which of the following helps isolate units of code for testing in TDD?

·        A) Caching

·        B) Mocking

·        C) Minification

·        D) Encryption

Answer: B) Mocking
Explanation: Mocks are used to isolate code under test by simulating dependencies.


Q14. What should be the size of test cases in TDD?

·        A) Large and comprehensive

·        B) Small and focused

·        C) Only UI-focused

·        D) As few as possible

Answer: B) Small and focused
Explanation: Each test should validate a small, specific unit of functionality.


Q15. Which of the following is not typically associated with TDD?

·        A) Behavior-driven development (BDD)

·        B) Refactoring

·        C) Feature-first design

·        D) Unit testing

Answer: C) Feature-first design
Explanation: TDD emphasizes writing tests before implementing features, not designing features first.

 

 

QUESTION NO. 6

📘 Single Page Application (SPA)


🧩 Section 1: Fundamentals of SPAs


Q1. What is a Single Page Application (SPA)?

·        A) A mobile application with one screen

·        B) A web app that loads a single HTML page and dynamically updates content

·        C) A desktop application built with C++

·        D) A static HTML file

Answer: B) A web app that loads a single HTML page and dynamically updates content
Explanation: SPAs load a single HTML file and update the page dynamically using JavaScript, avoiding full page reloads.


Q2. Which technology is most commonly used to make SPAs interactive without reloading the page?

·        A) PHP

·        B) Java

·        C) AJAX

·        D) MySQL

Answer: C) AJAX
Explanation: AJAX allows asynchronous communication with the server, enabling dynamic content updates in SPAs.


Q3. Which of the following is not typically a characteristic of an SPA?

·        A) Full-page reloads for navigation

·        B) Uses client-side routing

·        C) Faster user interaction after initial load

·        D) Heavy use of JavaScript

Answer: A) Full-page reloads for navigation
Explanation: SPAs avoid full-page reloads by updating the page with JavaScript when navigating between views.


Q4. What is the main benefit of a Single Page Application over a traditional multi-page app (MPA)?

·        A) Lower code complexity

·        B) Faster first-page load

·        C) Seamless user experience without reloads

·        D) Easier server configuration

Answer: C) Seamless user experience without reloads
Explanation: SPAs provide a fluid and responsive user experience by eliminating page reloads.


Q5. Which JavaScript frameworks are commonly used to build SPAs?

·        A) Angular, React, Vue

·        B) jQuery, Bootstrap, D3

·        C) Django, Laravel, Ruby on Rails

·        D) Flask, Spring, Express

Answer: A) Angular, React, Vue
Explanation: These frameworks offer routing, state management, and component-based architecture ideal for SPAs.


⚙️ Section 2: Architecture & Routing


Q6. Which module handles navigation in an Angular SPA?

·        A) FormsModule

·        B) HttpClientModule

·        C) RouterModule

·        D) BrowserModule

Answer: C) RouterModule
Explanation: Angular’s RouterModule manages client-side routing within an SPA.


Q7. In SPAs, how are different "pages" typically rendered?

·        A) Server sends new HTML

·        B) Entire app reloads

·        C) DOM is updated via JavaScript

·        D) IFrames are used

Answer: C) DOM is updated via JavaScript
Explanation: JavaScript dynamically renders components or views within the same page.


Q8. How does client-side routing in SPAs affect browser history?

·        A) It disables the back button

·        B) It replaces native navigation with hash or HTML5 history APIs

·        C) It requires server rendering

·        D) It triggers full-page reloads

Answer: B) It replaces native navigation with hash or HTML5 history APIs
Explanation: SPAs use the browser history API or hash fragments (#) to manage client-side routes.


🚀 Section 3: Performance & Optimization


Q9. What is one downside of SPAs?

·        A) Reduced JavaScript usage

·        B) Poor offline support

·        C) SEO challenges

·        D) Requires multiple servers

Answer: C) SEO challenges
Explanation: Because content is dynamically loaded, search engines may not index it effectively without server-side rendering (SSR).


Q10. Which solution helps improve SEO for SPAs?

·        A) LocalStorage

·        B) JSON APIs

·        C) Server-Side Rendering (SSR)

·        D) CSS modules

Answer: C) Server-Side Rendering (SSR)
Explanation: SSR pre-renders HTML content for search engines, helping improve discoverability.


Q11. What technique is used in SPAs to reduce the initial bundle size?

·        A) Polling

·        B) Lazy Loading

·        C) Cookies

·        D) Socket Streaming

Answer: B) Lazy Loading
Explanation: Lazy loading delays loading of code or components until they are needed, improving performance.


Q12. What typically happens on the first load of an SPA?

·        A) HTML and CSS only are fetched

·        B) A full reload for every route

·        C) The full JavaScript bundle and HTML are downloaded

·        D) The app requests every view at once

Answer: C) The full JavaScript bundle and HTML are downloaded
Explanation: The initial load downloads all necessary JavaScript to render the app and route navigation.


🔐 Section 4: Security & Best Practices


Q13. Which of the following security risks are common in SPAs?

·        A) SQL Injection

·        B) CSRF

·        C) XSS (Cross-site Scripting)

·        D) Buffer Overflow

Answer: C) XSS (Cross-site Scripting)
Explanation: SPAs are vulnerable to XSS because they render dynamic content from JavaScript.


Q14. What should SPAs use to secure API calls to a backend server?

·        A) Static tokens

·        B) IP whitelisting

·        C) JSONP

·        D) JWT (JSON Web Tokens)

Answer: D) JWT (JSON Web Tokens)
Explanation: JWT is a widely used method to authorize API requests from SPAs securely.


Q15. In a secure SPA, where should access tokens not be stored?

·        A) Memory

·        B) Session Storage

·        C) Cookies with HttpOnly flag

·        D) LocalStorage

Answer: D) LocalStorage
Explanation: LocalStorage is vulnerable to XSS attacks and is not the safest place for sensitive tokens.

 

 

QUESTION NO 7:

📘 Database Indexes


🧩 Section 1: Basics of Indexing


Q1. What is the main purpose of an index in a database?

·        A) To store relationships

·        B) To remove duplicates

·        C) To speed up data retrieval

·        D) To normalize data

Answer: C) To speed up data retrieval
Explanation: Indexes improve query performance by allowing faster access to rows.


Q2. Which data structure is commonly used for implementing indexes in relational databases?

·        A) Queue

·        B) Graph

·        C) B-Tree

·        D) Linked List

Answer: C) B-Tree
Explanation: B-Trees are widely used due to their balanced structure and efficient search performance.


Q3. What happens if a table has no indexes?

·        A) Data cannot be inserted

·        B) Joins are disabled

·        C) The database performs a full table scan for every query

·        D) Only SELECT statements are allowed

Answer: C) The database performs a full table scan for every query
Explanation: Without an index, the database must examine every row to find matching data.


Q4. Which type of index enforces uniqueness on the column values?

·        A) Clustered index

·        B) Hash index

·        C) Unique index

·        D) Composite index

Answer: C) Unique index
Explanation: A unique index ensures that no two rows have the same value in the indexed column.


Q5. Can an index be created on more than one column?

·        A) No

·        B) Yes, it's called a composite index

·        C) Yes, but only on numeric columns

·        D) Only in NoSQL databases

Answer: B) Yes, it's called a composite index
Explanation: Composite indexes include multiple columns to optimize queries involving all or some of those columns.


⚙️ Section 2: Types of Indexes


Q6. Which of the following best describes a clustered index?

·        A) An index that points to another index

·        B) An index where the table data is stored in the index order

·        C) An index stored in memory only

·        D) An index used for backup

Answer: B) An index where the table data is stored in the index order
Explanation: Clustered indexes determine the physical order of data in the table.


Q7. How many clustered indexes can a table have?

·        A) Unlimited

·        B) 2

·        C) Only 1

·        D) 1 per primary key

Answer: C) Only 1
Explanation: Because the clustered index defines the order of physical storage, a table can have only one.


Q8. Which index type is most suitable for equality comparisons (e.g., WHERE id = 10)?

·        A) Clustered index

·        B) Bitmap index

·        C) Hash index

·        D) Spatial index

Answer: C) Hash index
Explanation: Hash indexes provide fast lookup for equality-based queries.


Q9. A bitmap index is best suited for:

·        A) High-cardinality columns

·        B) Columns with unique values

·        C) Low-cardinality columns (e.g., gender, status)

·        D) Binary data storage

Answer: C) Low-cardinality columns
Explanation: Bitmap indexes are efficient for columns with few distinct values.


Q10. Which index type is used for full-text search capabilities?

·        A) Clustered index

·        B) Full-text index

·        C) Composite index

·        D) Unique index

Answer: B) Full-text index
Explanation: Full-text indexes enable keyword searches within text data, supporting queries like MATCH...AGAINST.


🧪 Section 3: Performance & Best Practices


Q11. What is a potential disadvantage of having too many indexes on a table?

·        A) Increased CPU speed

·        B) Slower query execution

·        C) Increased storage and slower write performance

·        D) Inaccurate results

Answer: C) Increased storage and slower write performance
Explanation: Each index must be updated on INSERT, UPDATE, and DELETE, which can degrade performance.


Q12. When is it not recommended to use an index?

·        A) For large tables

·        B) For columns with many NULL values

·        C) For frequently searched fields

·        D) For JOIN operations

Answer: B) For columns with many NULL values
Explanation: Indexes are less effective when most values are NULL, especially in WHERE clause filters.


Q13. Which clause in SQL helps avoid creating redundant indexes?

·        A) WHERE

·        B) HAVING

·        C) IF NOT EXISTS

·        D) GROUP BY

Answer: C) IF NOT EXISTS
Explanation: The IF NOT EXISTS clause prevents attempts to create duplicate indexes.


Q14. What command is used to remove an index in SQL?

·        A) DROP COLUMN

·        B) DELETE INDEX

·        C) DROP INDEX

·        D) REMOVE INDEX

Answer: C) DROP INDEX
Explanation: DROP INDEX removes an existing index from a table.


Q15. Which SQL keyword creates an index?

·        A) CREATE INDEX

·        B) INSERT INDEX

·        C) ALTER INDEX

·        D) SELECT INDEX

Answer: A) CREATE INDEX
Explanation: CREATE INDEX is the standard SQL command to define a new index on a table.

 

QUESTION NO 8:

📘 Database Views


🧩 Section 1: Basics of Views


Q1. What is a view in a relational database?

·        A) A physical table storing data

·        B) A temporary backup of a table

·        C) A virtual table based on a SQL query

·        D) A user role definition

Answer: C) A virtual table based on a SQL query
Explanation: A view is not a real table but a stored SQL query that behaves like a table in SELECT operations.


Q2. Which SQL keyword is used to create a view?

·        A) INSERT VIEW

·        B) SELECT VIEW

·        C) CREATE VIEW

·        D) MAKE VIEW

Answer: C) CREATE VIEW
Explanation: CREATE VIEW is used to define a new view in SQL.


Q3. Which of the following is true about views?

·        A) They permanently store data

·        B) They cannot be queried

·        C) They simplify complex SQL queries

·        D) They must be refreshed every hour

Answer: C) They simplify complex SQL queries
Explanation: Views are often used to simplify and reuse complex joins or filters.


Q4. Can a view be created from multiple tables?

·        A) No

·        B) Yes

·        C) Only with INNER JOIN

·        D) Only in NoSQL databases

Answer: B) Yes
Explanation: Views can be based on one or more tables using joins, unions, etc.


Q5. What happens when you query a view?

·        A) It returns cached results

·        B) It returns real-time data from the underlying tables

·        C) It duplicates the data

·        D) It calls a stored procedure

Answer: B) It returns real-time data from the underlying tables
Explanation: A view dynamically reflects data from the base tables at query time.


⚙️ Section 2: Types and Uses of Views


Q6. What is a materialized view?

·        A) A view that is only temporary

·        B) A view that stores actual data

·        C) A view that cannot be updated

·        D) A view for numeric data only

Answer: B) A view that stores actual data
Explanation: Unlike regular views, materialized views store the query results physically and may need refreshing.


Q7. Which of the following is not an advantage of views?

·        A) Improved security

·        B) Reduced data redundancy

·        C) Automatic indexing

·        D) Simplified access to complex queries

Answer: C) Automatic indexing
Explanation: Views do not automatically create indexes; indexing is done on the base tables or materialized views.


Q8. Why are views often used for security purposes?

·        A) They encrypt the database

·        B) They limit access to specific columns or rows

·        C) They enforce primary keys

·        D) They prevent all data modifications

Answer: B) They limit access to specific columns or rows
Explanation: Views can expose only the necessary part of a table to users, hiding sensitive data.


Q9. Which clause is used to define updatable views in SQL?

·        A) WITH JOIN

·        B) WITH CHECK OPTION

·        C) ON COMMIT

·        D) HAVING VIEW

Answer: B) WITH CHECK OPTION
Explanation: This clause ensures that inserted or updated rows meet the view's conditions.


Q10. Which of the following operations cannot be performed directly on a standard SQL view?

·        A) SELECT

·        B) INSERT

·        C) UPDATE

·        D) CREATE INDEX

Answer: D) CREATE INDEX
Explanation: You cannot create indexes directly on standard views; only on materialized views in some DBMSs.


🧪 Section 3: Limitations and Best Practices


Q11. Can all views be updated?

·        A) Yes

·        B) No

·        C) Only views on one table

·        D) Only in PostgreSQL

Answer: B) No
Explanation: Not all views are updatable, especially those using GROUP BY, joins, or aggregations.


Q12. What happens if a base table referenced by a view is dropped?

·        A) The view continues to work

·        B) The view stores previous data

·        C) The view becomes invalid

·        D) The view converts to a table

Answer: C) The view becomes invalid
Explanation: Views depend on base tables; dropping a table invalidates the view.


Q13. Which of the following SQL features can be used to refresh a materialized view?

·        A) REFRESH MATERIALIZED VIEW

·        B) UPDATE VIEW

·        C) ALTER INDEX

·        D) RECREATE VIEW

Answer: A) REFRESH MATERIALIZED VIEW
Explanation: This command updates the stored data in a materialized view.


Q14. Which of the following is a read-only view?

·        A) A view on a single table

·        B) A view with a primary key

·        C) A view with joins and aggregations

·        D) A view using WITH CHECK OPTION

Answer: C) A view with joins and aggregations
Explanation: Views that use complex operations like joins or GROUP BY are typically read-only.


Q15. What is one best practice when working with views?

·        A) Always create views with full SELECT *

·        B) Avoid using views in reporting

·        C) Use views to hide business logic and simplify queries

·        D) Always create indexes on views

Answer: C) Use views to hide business logic and simplify queries
Explanation: Views are ideal for abstracting complex logic and providing a clean interface to data.

 

 

QUESTION NO 9:

📘 Tools for RESTful API


🧩 Section 1: Development Tools


Q1. Which of the following tools is commonly used to create RESTful APIs with Node.js?

·        A) Express.js

·        B) Django

·        C) Laravel

·        D) Ruby on Rails

Answer: A) Express.js
Explanation: Express.js is a minimal and flexible Node.js web framework widely used for building RESTful APIs.


Q2. Which Python framework is most popular for developing RESTful APIs?

·        A) Flask

·        B) Angular

·        C) React

·        D) Spring Boot

Answer: A) Flask
Explanation: Flask is a lightweight Python web framework commonly used for building RESTful APIs.


Q3. What is Postman primarily used for?

·        A) Writing backend code

·        B) Testing and documenting APIs

·        C) Deploying APIs

·        D) Database management

Answer: B) Testing and documenting APIs
Explanation: Postman allows developers to test, debug, and document RESTful APIs interactively.


Q4. Which of the following tools helps generate API documentation automatically?

·        A) Swagger (OpenAPI)

·        B) Jenkins

·        C) Git

·        D) Docker

Answer: A) Swagger (OpenAPI)
Explanation: Swagger (OpenAPI Specification) is used to design, build, document, and consume RESTful APIs.


Q5. Which Java framework is known for building RESTful services?

·        A) Spring Boot

·        B) Angular

·        C) React

·        D) Vue.js

Answer: A) Spring Boot
Explanation: Spring Boot simplifies building RESTful APIs in Java by providing pre-configured setups.


⚙️ Section 2: Testing and Automation Tools


Q6. Which tool supports automated testing of RESTful APIs with scripting support?

·        A) Postman

·        B) MySQL

·        C) Redux

·        D) Bootstrap

Answer: A) Postman
Explanation: Postman includes scripting capabilities to automate tests on API endpoints.


Q7. Which CLI tool allows testing REST APIs from the command line?

·        A) cURL

·        B) Node.js

·        C) Maven

·        D) Gradle

Answer: A) cURL
Explanation: cURL is a command-line tool used to make HTTP requests and test APIs.


Q8. What is the main advantage of using tools like SoapUI for REST API testing?

·        A) Support only SOAP services

·        B) Support both REST and SOAP services

·        C) Generates Java code automatically

·        D) Compiles JavaScript

Answer: B) Support both REST and SOAP services
Explanation: SoapUI can test both RESTful and SOAP web services.


Q9. Which CI/CD tool can be used to automate REST API tests as part of the build pipeline?

·        A) Jenkins

·        B) Photoshop

·        C) Eclipse

·        D) MySQL

Answer: A) Jenkins
Explanation: Jenkins automates software tasks including running API tests during CI/CD pipelines.


Q10. What is the purpose of Swagger UI?

·        A) To deploy APIs

·        B) To provide a graphical interface for API documentation and testing

·        C) To write backend code

·        D) To manage databases

Answer: B) To provide a graphical interface for API documentation and testing
Explanation: Swagger UI renders OpenAPI specs as interactive web pages for easy API exploration.


🚀 Section 3: API Monitoring and Security Tools


Q11. Which tool can monitor REST API uptime and performance?

·        A) Postman

·        B) New Relic

·        C) Visual Studio Code

·        D) Jenkins

Answer: B) New Relic
Explanation: New Relic provides real-time monitoring for APIs and applications.


Q12. What does OAuth help secure in RESTful APIs?

·        A) Data storage

·        B) User authentication and authorization

·        C) API documentation

·        D) Server deployment

Answer: B) User authentication and authorization
Explanation: OAuth is an authorization protocol used to secure API access.


Q13. Which API gateway tool helps manage, secure, and monitor APIs?

·        A) Kong

·        B) Jenkins

·        C) Docker

·        D) Selenium

Answer: A) Kong
Explanation: Kong is an API gateway that provides security, rate limiting, and analytics for APIs.


Q14. What is the use of API mocking tools like Mockoon or Postman Mock Server?

·        A) To deploy APIs to production

·        B) To simulate API endpoints during development

·        C) To document APIs

·        D) To secure APIs

Answer: B) To simulate API endpoints during development
Explanation: Mocking tools allow developers to test client-side apps without a live backend.


Q15. Which format is commonly used for RESTful API payloads?

·        A) CSV

·        B) XML

·        C) JSON

·        D) EXE

Answer: C) JSON
Explanation: JSON is lightweight and widely adopted for REST API communication.

 

 

QUESTION NO 10:

📘 REST (Representational State Transfer)


🧩 Section 1: REST Basics


Q1. What does REST stand for?

·        A) Representational State Transfer

·        B) Remote State Transfer

·        C) Real-time Server Transfer

·        D) Resource State Transfer

Answer: A) Representational State Transfer
Explanation: REST is an architectural style for designing networked applications.


Q2. Which HTTP method is typically used to retrieve data in RESTful services?

·        A) POST

·        B) GET

·        C) PUT

·        D) DELETE

Answer: B) GET
Explanation: GET requests data from a specified resource.


Q3. Which HTTP method is used to create a new resource?

·        A) GET

·        B) POST

·        C) DELETE

·        D) PATCH

Answer: B) POST
Explanation: POST submits data to be processed and creates a new resource.


Q4. What is the key principle of REST that ensures statelessness?

·        A) The server stores client session state

·        B) Each request contains all information necessary to complete the request

·        C) The client maintains all stateful info on the server

·        D) Requests can depend on previous interactions

Answer: B) Each request contains all information necessary to complete the request
Explanation: RESTful APIs are stateless; server does not store client context.


Q5. What kind of data format is most commonly used in REST APIs?

·        A) XML

·        B) CSV

·        C) JSON

·        D) YAML

Answer: C) JSON
Explanation: JSON is lightweight, easy to read, and widely supported.


⚙️ Section 2: REST Constraints and Concepts


Q6. Which of the following is not a constraint of REST architecture?

·        A) Statelessness

·        B) Client-server architecture

·        C) Use of XML only

·        D) Cacheability

Answer: C) Use of XML only
Explanation: REST can use various data formats; XML is not mandatory.


Q7. What does the term resource mean in REST?

·        A) A database

·        B) A server

·        C) Any piece of information identified by a URI

·        D) A client request

Answer: C) Any piece of information identified by a URI
Explanation: Resources are entities like users, images, or services accessible via URLs.


Q8. Which status code indicates a successful HTTP GET request?

·        A) 200

·        B) 404

·        C) 500

·        D) 302

Answer: A) 200
Explanation: 200 OK means the request succeeded.


Q9. In REST, which HTTP method is used to update an existing resource completely?

·        A) POST

·        B) PATCH

·        C) PUT

·        D) DELETE

Answer: C) PUT
Explanation: PUT replaces the entire resource with the new representation.


Q10. What is the difference between PUT and PATCH methods?

·        A) PUT deletes a resource, PATCH creates it

·        B) PUT partially updates, PATCH replaces the resource

·        C) PUT replaces the entire resource, PATCH partially updates it

·        D) No difference

Answer: C) PUT replaces the entire resource, PATCH partially updates it
Explanation: PATCH applies partial modifications without replacing the entire resource.


🧪 Section 3: RESTful Best Practices


Q11. What HTTP status code is typically returned after successfully deleting a resource?

·        A) 201

·        B) 204

·        C) 400

·        D) 404

Answer: B) 204
Explanation: 204 No Content means the deletion was successful with no content returned.


Q12. Which header is commonly used to specify the media type of the resource in REST?

·        A) Content-Type

·        B) Accept-Encoding

·        C) User-Agent

·        D) Cache-Control

Answer: A) Content-Type
Explanation: Content-Type header specifies the format of the data sent by the client or server.


Q13. In REST, what does HATEOAS stand for?

·        A) Hypermedia As The Engine Of Application State

·        B) Hypertext And Text Engine Over Application Server

·        C) Hypermedia As The Endpoint Of Application Service

·        D) Hyper Application Transfer Engine On Server

Answer: A) Hypermedia As The Engine Of Application State
Explanation: HATEOAS allows clients to dynamically navigate resources via hyperlinks.


Q14. Which URI design is considered RESTful?

·        A) /getUser?id=123

·        B) /user/123

·        C) /fetchUserDetails

·        D) /action=user&value=123

Answer: B) /user/123
Explanation: RESTful URIs identify resources via nouns rather than verbs.


Q15. RESTful APIs typically use which protocol?

·        A) FTP

·        B) SMTP

·        C) HTTP/HTTPS

·        D) TCP

Answer: C) HTTP/HTTPS
Explanation: REST is designed to work over HTTP or HTTPS protocols.

 

 

QUESTION NO 11:

📘 REST & GraphQL


🧩 Section 1: REST Fundamentals


Q1. What does REST stand for?

·        A) Representational State Transfer

·        B) Remote Server Transfer

·        C) Resource State Transfer

·        D) Representational Service Technology

Answer: A) Representational State Transfer


Q2. Which HTTP method is used to retrieve data in REST?

·        A) POST

·        B) GET

·        C) PUT

·        D) DELETE

Answer: B) GET


Q3. REST APIs typically use which data format for requests and responses?

·        A) JSON

·        B) CSV

·        C) YAML

·        D) EXE

Answer: A) JSON


Q4. Which constraint of REST means each request must contain all necessary information for the server to fulfill it?

·        A) Cacheability

·        B) Statelessness

·        C) Client-server architecture

·        D) Layered system

Answer: B) Statelessness


🧩 Section 2: GraphQL Fundamentals


Q5. Who developed GraphQL?

·        A) Google

·        B) Facebook

·        C) Microsoft

·        D) Amazon

Answer: B) Facebook


Q6. What is the main advantage of GraphQL over REST?

·        A) Uses XML instead of JSON

·        B) Clients can request exactly the data they need

·        C) Requires multiple endpoints for each resource

·        D) Uses HTTP only for subscriptions

Answer: B) Clients can request exactly the data they need


Q7. In GraphQL, what is a query?

·        A) A way to modify data

·        B) A way to fetch data

·        C) A subscription type

·        D) An error response

Answer: B) A way to fetch data


Q8. What are the two main operations in GraphQL?

·        A) GET and POST

·        B) Query and Mutation

·        C) PUT and DELETE

·        D) Subscribe and Poll

Answer: B) Query and Mutation


🧩 Section 3: Comparing REST and GraphQL


Q9. How does REST handle fetching related data compared to GraphQL?

·        A) REST requires multiple requests for related data; GraphQL fetches it in one request

·        B) REST can fetch all related data in one request by default

·        C) GraphQL requires multiple requests, REST only one

·        D) Both require the same number of requests

Answer: A) REST requires multiple requests for related data; GraphQL fetches it in one request


Q10. Which approach uses fixed endpoints for resources?

·        A) REST

·        B) GraphQL

·        C) Both

·        D) Neither

Answer: A) REST


Q11. Which technology allows clients to specify exact fields they want in the response?

·        A) REST

·        B) GraphQL

·        C) SOAP

·        D) gRPC

Answer: B) GraphQL


Q12. How does REST communicate errors typically?

·        A) HTTP status codes (e.g., 404, 500)

·        B) Custom error messages only

·        C) GraphQL error objects

·        D) By disconnecting the client

Answer: A) HTTP status codes (e.g., 404, 500)


Q13. Which of the following is true about versioning in REST vs. GraphQL?

·        A) REST often uses versioned endpoints like /v1/users

·        B) GraphQL encourages evolving the schema without versioning

·        C) Both use the same versioning approach

·        D) Neither support versioning

Answer: A and B are both true


🧩 Section 4: Advanced Concepts


Q14. Which GraphQL feature supports real-time updates?

·        A) Queries

·        B) Mutations

·        C) Subscriptions

·        D) Triggers

Answer: C) Subscriptions


Q15. Which tool is commonly used to explore and test GraphQL APIs?

·        A) Postman

·        B) GraphiQL

·        C) Swagger UI

·        D) SoapUI

Answer: B) GraphiQL


Q16. In REST, what is the purpose of the HTTP OPTIONS method?

·        A) Retrieve resource data

·        B) Delete a resource

·        C) Get allowed HTTP methods on a resource

·        D) Update part of a resource

Answer: C) Get allowed HTTP methods on a resource


Q17. What is the typical transport protocol for both REST and GraphQL?

·        A) FTP

·        B) SMTP

·        C) HTTP/HTTPS

·        D) TCP

Answer: C) HTTP/HTTPS

 

QUESTION NO. 12:

📘 Object-Oriented Programming (OOP) Features


🧩 Section 1: Basics of OOP


Q1. Which of the following is NOT a fundamental feature of Object-Oriented Programming?

·        A) Encapsulation

·        B) Inheritance

·        C) Polymorphism

·        D) Compilation

Answer: D) Compilation
Explanation: Compilation is a process, not an OOP feature.


Q2. What is Encapsulation in OOP?

·        A) The ability of objects to take many forms

·        B) Wrapping data and methods into a single unit

·        C) Deriving new classes from existing ones

·        D) Hiding the internal details of an object

Answer: B) Wrapping data and methods into a single unit
Explanation: Encapsulation bundles variables and functions that manipulate them together.


Q3. What is Inheritance in OOP?

·        A) Ability to hide internal data

·        B) Creating new classes from existing classes

·        C) Defining multiple methods with the same name

·        D) Hiding data members

Answer: B) Creating new classes from existing classes
Explanation: Inheritance allows code reuse by creating a subclass from a superclass.


Q4. What is Polymorphism?

·        A) Ability of a variable to change its type dynamically

·        B) Ability of objects to behave differently based on context

·        C) Combining data and functions

·        D) Restricting access to certain components

Answer: B) Ability of objects to behave differently based on context
Explanation: Polymorphism allows methods to perform different tasks based on the object.


Q5. What is Abstraction in OOP?

·        A) Hiding complexity and showing only essential features

·        B) Inheriting properties from another class

·        C) Having multiple methods with the same name

·        D) Data hiding

Answer: A) Hiding complexity and showing only essential features
Explanation: Abstraction focuses on essential qualities rather than specific details.


⚙️ Section 2: Concepts and Applications


Q6. Which keyword is used to inherit a class in Java?

·        A) implement

·        B) extends

·        C) inherits

·        D) derives

Answer: B) extends


Q7. Which of the following allows method overloading?

·        A) Same method name with different return types

·        B) Same method name with different parameters

·        C) Different method names with same parameters

·        D) Same method name with same parameters

Answer: B) Same method name with different parameters


Q8. Which type of polymorphism is resolved at runtime?

·        A) Compile-time polymorphism

·        B) Runtime polymorphism

·        C) Method overloading

·        D) Operator overloading

Answer: B) Runtime polymorphism


Q9. Which of these is an example of runtime polymorphism?

·        A) Method overloading

·        B) Method overriding

·        C) Operator overloading

·        D) Constructor overloading

Answer: B) Method overriding


Q10. What does data hiding refer to?

·        A) Making data members private so they cannot be accessed directly

·        B) Deleting unused data

·        C) Encrypting data

·        D) Writing data to a file

Answer: A) Making data members private so they cannot be accessed directly


🧪 Section 3: OOP Design Principles


Q11. What does “IS-A” relationship signify in OOP?

·        A) Inheritance between classes

·        B) Composition

·        C) Aggregation

·        D) Association

Answer: A) Inheritance between classes


Q12. Which OOP principle promotes code reusability?

·        A) Encapsulation

·        B) Abstraction

·        C) Inheritance

·        D) Polymorphism

Answer: C) Inheritance


Q13. Which access specifier allows a class member to be accessible only within its own class?

·        A) public

·        B) private

·        C) protected

·        D) internal

Answer: B) private


Q14. What is method overriding?

·        A) Defining multiple methods with same name but different parameters

·        B) Redefining a method in the subclass with the same signature as in superclass

·        C) Creating a new method in a class

·        D) Overloading the method with different return types

Answer: B) Redefining a method in the subclass with the same signature as in superclass


Q15. Which feature of OOP allows multiple methods with the same name but different parameters?

·        A) Method overriding

·        B) Method overloading

·        C) Polymorphism

·        D) Encapsulation

Answer: B) Method overloading

 

QUESETION NO. 13:

📘 Encapsulation  


🧩 Section: Understanding Encapsulation


Q1. What is encapsulation in object-oriented programming?

·        A) The process of inheriting properties from another class

·        B) Wrapping data and methods into a single unit and restricting access

·        C) Allowing multiple methods with the same name but different parameters

·        D) Creating new objects from a class

Answer: B) Wrapping data and methods into a single unit and restricting access


Q2. Which of the following best describes the main purpose of encapsulation?

·        A) To hide the internal state of an object from outside access

·        B) To allow direct access to class variables

·        C) To speed up code execution

·        D) To allow multiple inheritance

Answer: A) To hide the internal state of an object from outside access


Q3. What is typically used in many programming languages to restrict direct access to an object’s data?

·        A) Public variables

·        B) Private variables

·        C) Static methods

·        D) Abstract classes

Answer: B) Private variables


Q4. How do we allow controlled access to private variables in a class?

·        A) By using public getter and setter methods

·        B) By making the variables static

·        C) By using constructors only

·        D) By inheritance

Answer: A) By using public getter and setter methods


Q5. Encapsulation improves which of the following?

·        A) Security of data

·        B) Program execution speed

·        C) Hardware performance

·        D) Network communication

Answer: A) Security of data


⚙️ Section: Practical Applications of Encapsulation


Q6. Which access modifier in Java restricts access to members only within the class?

·        A) public

·        B) private

·        C) protected

·        D) default

Answer: B) private


Q7. Which of the following is NOT a benefit of encapsulation?

·        A) Code maintainability

·        B) Data hiding

·        C) Increased coupling

·        D) Flexibility to change internal implementation

Answer: C) Increased coupling


Q8. When encapsulation is properly implemented, what can be said about the object’s internal data?

·        A) It can be accessed directly by other objects

·        B) It cannot be accessed or modified directly from outside the object

·        C) It is publicly visible by default

·        D) It must be static

Answer: B) It cannot be accessed or modified directly from outside the object


Q9. Which statement is true about encapsulation?

·        A) It enforces a strict boundary around data and code

·        B) It allows data to be publicly modified

·        C) It requires using multiple inheritance

·        D) It does not affect code modularity

Answer: A) It enforces a strict boundary around data and code


Q10. Encapsulation helps to achieve which other OOP principle?

·        A) Polymorphism

·        B) Abstraction

·        C) Inheritance

·        D) Overloading

Answer: B) Abstraction

 

QUESTIO NO 14:

📘 Configuration in Microservices .


🧩 Section 1: General Concepts


Q1. What is the main purpose of configuration in a microservice architecture?

·        A) To compile microservices

·        B) To define behavior and settings without changing the code

·        C) To perform load balancing

·        D) To execute database transactions

Answer: B) To define behavior and settings without changing the code


Q2. Which of the following is a common method to store configuration data in microservices?

·        A) Database tables

·        B) Environment variables

·        C) DNS entries

·        D) JavaScript files

Answer: B) Environment variables


Q3. What is a benefit of externalized configuration in microservices?

·        A) Configuration is compiled into the binary

·        B) Configuration changes require application redeployment

·        C) Configuration can be changed without restarting the service

·        D) Configuration is always the same for all environments

Answer: C) Configuration can be changed without restarting the service


Q4. Which tool is commonly used for centralized configuration management in Spring Cloud?

·        A) Consul

·        B) etcd

·        C) Spring Cloud Config

·        D) Helm

Answer: C) Spring Cloud Config


Q5. Which of the following configuration formats is commonly used in microservices?

·        A) YAML

·        B) PDF

·        C) DOCX

·        D) TXT

Answer: A) YAML


⚙️ Section 2: Centralized Configuration & Environment Handling


Q6. In a centralized configuration service, where is configuration typically fetched from?

·        A) Each individual service's local file

·        B) A shared Git repository or configuration server

·        C) Static files in the service binary

·        D) A Kubernetes dashboard

Answer: B) A shared Git repository or configuration server


Q7. What is the main reason for using profiles (e.g., dev, test, prod) in microservice configuration?

·        A) To version control the codebase

·        B) To load specific settings per environment

·        C) To build container images

·        D) To set IP addresses

Answer: B) To load specific settings per environment


Q8. In Kubernetes, how are configuration values injected into microservices?

·        A) Through inline shell scripts

·        B) Using ConfigMaps and Secrets

·        C) Only through hardcoded variables

·        D) Via load balancers

Answer: B) Using ConfigMaps and Secrets


Q9. What is the purpose of a Secret in Kubernetes?

·        A) To monitor services

·        B) To expose services to the internet

·        C) To store sensitive configuration like passwords or tokens

·        D) To run cron jobs

Answer: C) To store sensitive configuration like passwords or tokens


Q10. Which of the following is NOT a common configuration management tool used in microservices?

·        A) Consul

·        B) Ansible

·        C) Spring Cloud Config

·        D) GitHub Actions

Answer: D) GitHub Actions
Explanation: GitHub Actions is for CI/CD, not direct configuration management.


🧪 Section 3: Best Practices


Q11. What is the best practice for handling API keys and secrets in microservices?

·        A) Hardcode them in the source code

·        B) Store them in a public Git repository

·        C) Use a secrets management system

·        D) Embed them in logs

Answer: C) Use a secrets management system


Q12. Why should configurations be externalized from the microservice code?

·        A) To avoid needing a service mesh

·        B) To ensure CI/CD integration

·        C) To allow dynamic updates without code redeployment

·        D) To reduce YAML file usage

Answer: C) To allow dynamic updates without code redeployment


Q13. Which of the following tools supports key/value storage for distributed configurations?

·        A) Jenkins

·        B) Docker Compose

·        C) HashiCorp Consul

·        D) Grafana

Answer: C) HashiCorp Consul


Q14. In microservices, where should configuration changes ideally be tracked?

·        A) In spreadsheets

·        B) In source control (e.g., Git)

·        C) In service logs

·        D) In Docker images

Answer: B) In source control (e.g., Git)


Q15. Which statement is true regarding service-specific configuration in microservices?

·        A) All microservices must use the same configuration

·        B) Configuration should be hardcoded for security

·        C) Each service can have its own isolated configuration

·        D) Configuration must always be defined in a database

Answer: C) Each service can have its own isolated configuration

 

 

QUESTION NO 13.

MCQs: Encapsulation in OOP


1. What is encapsulation in object-oriented programming?
A) Hiding code from users
B) Wrapping data and methods into a single unit
C) Inheriting from another class
D) Making variables global
Answer: B


2. What is the main purpose of encapsulation?
A) To improve performance
B) To protect data and restrict direct access to it
C) To write shorter code
D) To allow multiple inheritance
Answer: B


3. Which access modifier in many programming languages supports encapsulation by hiding data?
A) public
B) private
C) global
D) static
Answer: B


4. In encapsulation, how is access to private variables typically provided?
A) Through loops
B) Via public getter and setter methods
C) Through static variables
D) By exposing them directly
Answer: B


5. Which of the following is NOT a benefit of encapsulation?
A) Code maintainability
B) Data hiding
C) Controlled access
D) Increased memory usage
Answer: D


6. What happens if encapsulation is not used in a program?
A) Code becomes faster
B) Data can be accessed and modified freely, leading to potential errors
C) Security increases
D) More classes are required
Answer: B


7. In Java, which keyword is used to declare a method or variable as not directly accessible from outside the class?
A) protected
B) private
C) final
D) public
Answer: B


8. Which concept in OOP ensures that internal representation of an object is hidden from the outside?
A) Inheritance
B) Polymorphism
C) Encapsulation
D) Abstraction
Answer: C


9. Which principle does encapsulation support directly?
A) Reusability
B) Data hiding
C) Code redundancy
D) Multiple inheritance
Answer: B


10. What is a real-world example of encapsulation?
A) Using public transportation
B) A light switch
C) A capsule that contains medicine (data + methods inside a container)
D) A book cover
Answer: C

 

QUESTION NO 14.

MCQs: Configuration in Microservices


1. Where should configuration values be ideally stored in a microservices architecture?
A) Hardcoded in the application code
B) Inside the database
C) Externalized in configuration files or services
D) Embedded in the container image
Answer: C


2. Which of the following is a benefit of externalizing configuration in microservices?
A) Better performance
B) Easier to update without redeploying services
C) Prevents service discovery
D) Avoids use of environment variables
Answer: B


3. What is a centralized configuration server typically used for in microservices?
A) Handling API authentication
B) Monitoring service health
C) Managing configuration values for multiple services in one place
D) Handling load balancing
Answer: C


4. Which tool is commonly used for centralized configuration in Spring-based microservices?
A) Kafka
B) Spring Cloud Config Server
C) Jenkins
D) Prometheus
Answer: B


5. In 12-Factor App methodology, configuration should be:
A) Stored in the codebase
B) Stored in the environment
C) Managed by the database
D) Ignored during testing
Answer: B


6. Which of the following is an advantage of using environment-specific configuration?
A) Slower deployments
B) Conflicts between services
C) Different settings for dev, test, and production
D) Shared secrets between services
Answer: C


7. In Dockerized microservices, configuration is often passed using:
A) TCP ports
B) Environment variables or mounted config files
C) Static routes
D) Manual edits after deployment
Answer: B


8. Which format is commonly used for storing configuration files?
A) PDF
B) MP4
C) YAML / JSON / Properties files
D) ZIP
Answer: C


9. What should be avoided when managing microservice configurations?
A) Using version control
B) Hardcoding secrets like passwords and tokens
C) Using environment-specific profiles
D) Using ConfigMaps in Kubernetes
Answer: B


10. What’s the role of a feature flag in microservice configuration?
A) Handling routing logic
B) Enabling or disabling features without code changes
C) Managing database credentials
D) Resolving service discovery
Answer: B

 

 

QUESTION NO. 15:

📈 Performance Monitoring Tools


🧩 Section 1: General Concepts


Q1. What is the primary purpose of performance monitoring tools?

·        A) To deploy applications

·        B) To measure system and application behavior

·        C) To write unit tests

·        D) To manage databases

Answer: B) To measure system and application behavior


Q2. Which of the following is NOT a performance monitoring tool?

·        A) Prometheus

·        B) Grafana

·        C) Kubernetes

·        D) Datadog

Answer: C) Kubernetes
Explanation: Kubernetes is a container orchestration platform, not a monitoring tool.


Q3. Which metric is commonly used to evaluate the performance of a microservice?

·        A) API version

·        B) Response time

·        C) Log file size

·        D) Database schema name

Answer: B) Response time


Q4. What does APM stand for in monitoring?

·        A) Application Performance Manager

·        B) Application Programming Model

·        C) Application Performance Monitoring

·        D) Advanced Platform Management

Answer: C) Application Performance Monitoring


Q5. Which of the following tools is mainly used for time-series data monitoring?

·        A) MySQL

·        B) Prometheus

·        C) Jenkins

·        D) MongoDB

Answer: B) Prometheus


⚙️ Section 2: Tool-Specific Monitoring


Q6. Which monitoring tool provides dashboards for visualizing metrics collected from Prometheus?

·        A) Logstash

·        B) Kibana

·        C) Grafana

·        D) Elasticsearch

Answer: C) Grafana


Q7. What is the primary role of New Relic?

·        A) Source code management

·        B) Network configuration

·        C) Application performance monitoring

·        D) Container orchestration

Answer: C) Application performance monitoring


Q8. In the ELK Stack, which tool is responsible for storing logs?

·        A) Logstash

·        B) Kibana

·        C) Elasticsearch

·        D) Beats

Answer: C) Elasticsearch


Q9. Datadog is a platform that provides:

·        A) Code refactoring suggestions

·        B) End-to-end observability of infrastructure, logs, and applications

·        C) Email notifications only

·        D) Real-time chat support

Answer: B) End-to-end observability of infrastructure, logs, and applications


Q10. Which monitoring tool uses a pull-based model to scrape metrics?

·        A) New Relic

·        B) Prometheus

·        C) Datadog

·        D) AppDynamics

Answer: B) Prometheus


🧪 Section 3: Performance Metrics & Best Practices


Q11. Which of these is a performance metric you can track with monitoring tools?

·        A) HTTP status codes

·        B) CPU usage

·        C) User profile data

·        D) File upload size

Answer: B) CPU usage


Q12. What does MTTR stand for in monitoring and performance metrics?

·        A) Maximum Time To Repair

·        B) Mean Time To Recovery

·        C) Monthly Technical Trouble Report

·        D) Minimum Time To Respond

Answer: B) Mean Time To Recovery


Q13. What is tracing in performance monitoring?

·        A) Recording SQL queries

·        B) Tracking code syntax

·        C) Following the flow of a request across services

·        D) Measuring server temperature

Answer: C) Following the flow of a request across services


Q14. What is the function of alerting in monitoring systems?

·        A) To automatically deploy updates

·        B) To notify teams when metrics exceed thresholds

·        C) To clean up logs

·        D) To encrypt sensitive data

Answer: B) To notify teams when metrics exceed thresholds


Q15. Which of the following tools supports distributed tracing out-of-the-box?

·        A) Prometheus

·        B) Grafana

·        C) Jaeger

·        D) Kibana

Answer: C) Jaeger

 

QUESTION NO 16:

Code Review


🧩 Section 1: Code Review Fundamentals


Q1. What is the primary purpose of a code review?

·        A) To refactor code

·        B) To catch bugs and improve code quality before merging

·        C) To deploy applications

·        D) To measure system performance

Answer: B) To catch bugs and improve code quality before merging


Q2. When should code reviews ideally take place?

·        A) After deployment

·        B) Before code is merged into the main branch

·        C) During production testing

·        D) After creating a new feature branch

Answer: B) Before code is merged into the main branch


Q3. Which of the following is NOT a common goal of code review?

·        A) Improve code readability

·        B) Enforce consistent coding styles

·        C) Monitor server performance

·        D) Share knowledge across the team

Answer: C) Monitor server performance


Q4. What is the ideal size for a code review, as recommended by industry best practices?

·        A) 1000+ lines

·        B) 50–400 lines

·        C) 5000+ lines

·        D) Any size is fine

Answer: B) 50–400 lines


Q5. Which of the following is a common code review tool?

·        A) Grafana

·        B) Jenkins

·        C) GitHub Pull Requests

·        D) Kubernetes Dashboard

Answer: C) GitHub Pull Requests


⚙️ Section 2: What to Check in a Code Review


Q6. Which of the following should be checked during a code review?

·        A) Code readability

·        B) Developer's keyboard layout

·        C) IP addresses

·        D) Operating system used

Answer: A) Code readability


Q7. What should be done if a reviewer finds a small but repeated issue in code (e.g., incorrect naming)?

·        A) Ignore it

·        B) Point it out with one example and suggest a general fix

·        C) Fix it silently

·        D) Escalate to project manager

Answer: B) Point it out with one example and suggest a general fix


Q8. In a professional code review, feedback should be:

·        A) Direct and hostile

·        B) Avoided unless critical

·        C) Constructive and respectful

·        D) Anonymous

Answer: C) Constructive and respectful


Q9. Which of the following is not typically reviewed in a pull request?

·        A) Code logic

·        B) Coding standards

·        C) Server resource usage

·        D) Unit tests

Answer: C) Server resource usage


Q10. Which principle helps reduce the complexity of code and should be encouraged in reviews?

·        A) DRY (Don’t Repeat Yourself)

·        B) RTFM

·        C) YOLO

·        D) ASAP

Answer: A) DRY (Don’t Repeat Yourself)


🧪 Section 3: Review Process & Best Practices


Q11. Who is responsible for addressing the feedback provided in a code review?

·        A) Product Owner

·        B) Reviewer

·        C) Developer who wrote the code

·        D) Scrum Master

Answer: C) Developer who wrote the code


Q12. What should a developer do before submitting code for review?

·        A) Skip testing

·        B) Run and pass all tests

·        C) Comment all lines

·        D) Merge directly to main

Answer: B) Run and pass all tests


Q13. Why is it important to write meaningful commit messages in a PR?

·        A) So GitHub loads faster

·        B) To improve traceability and context for reviewers

·        C) To trick reviewers

·        D) It’s not important

Answer: B) To improve traceability and context for reviewers


Q14. In larger teams, what is the benefit of having more than one reviewer?

·        A) Increases pressure

·        B) Reduces deployment time

·        C) Increases review quality and reduces bias

·        D) Delays development

Answer: C) Increases review quality and reduces bias


Q15. If a code review takes too long, what is the best practice?

·        A) Abandon the review

·        B) Merge anyway

·        C) Break the changes into smaller pull requests

·        D) Assign it to someone else without notice

Answer: C) Break the changes into smaller pull requests

 

QUESTION 17:

📘 Server-Side Rendering (SSR) Frameworks


🧩 Section 1: SSR Fundamentals


Q1. What does Server-Side Rendering (SSR) mean?

·        A) Rendering HTML in the browser

·        B) Rendering HTML on the server before sending to the client

·        C) Using JavaScript for API calls

·        D) Running CSS animations on the server

Answer: B) Rendering HTML on the server before sending to the client


Q2. What is a key advantage of SSR over client-side rendering (CSR)?

·        A) Slower performance

·        B) Reduced SEO capability

·        C) Better SEO and faster initial load time

·        D) Less control over HTML

Answer: C) Better SEO and faster initial load time


Q3. Which of the following frameworks is commonly used for SSR with React?

·        A) Nuxt.js

·        B) Next.js

·        C) Angular Universal

·        D) Ember.js

Answer: B) Next.js


Q4. Which SSR framework is built for Vue.js applications?

·        A) Next.js

·        B) Angular Universal

·        C) Nuxt.js

·        D) Express

Answer: C) Nuxt.js


Q5. Which Angular tool provides SSR support?

·        A) Angular Router

·        B) Angular CLI

·        C) Angular Universal

·        D) Angular Ivy

Answer: C) Angular Universal


⚙️ Section 2: SSR Framework Features


Q6. What command is typically used to run a Next.js app with SSR enabled?

·        A) next build

·        B) next start

·        C) npm run serve

·        D) vue-cli-service serve

Answer: B) next start


Q7. Which of these frameworks supports both static site generation (SSG) and SSR?

·        A) Next.js

·        B) React only

·        C) jQuery

·        D) Flask

Answer: A) Next.js


Q8. What type of rendering is Nuxt.js using by default in Universal mode?

·        A) Static rendering only

·        B) Server-side rendering

·        C) Client-side rendering

·        D) None

Answer: B) Server-side rendering


Q9. In SSR, what happens before the HTML is sent to the browser?

·        A) The DOM is parsed

·        B) All JavaScript executes in the browser

·        C) HTML is generated by the server

·        D) HTML is downloaded from CDN

Answer: C) HTML is generated by the server


Q10. What is hydration in the context of SSR?

·        A) Refreshing a webpage

·        B) Re-rendering the DOM

·        C) Adding interactivity to server-rendered static HTML

·        D) Fetching server memory

Answer: C) Adding interactivity to server-rendered static HTML


🧪 Section 3: SSR Best Practices & Use Cases


Q11. Why is SSR helpful for SEO?

·        A) HTML content is indexed faster by search engines

·        B) It adds more animations

·        C) It hides the content from bots

·        D) It slows down the page intentionally

Answer: A) HTML content is indexed faster by search engines


Q12. Which of the following is a drawback of SSR?

·        A) SEO issues

·        B) Increased server load

·        C) Less control over routing

·        D) Incompatible with HTML

Answer: B) Increased server load


Q13. Which of the following supports SSR for Svelte applications?

·        A) Nuxt

·        B) Next

·        C) SvelteKit

·        D) Angular Universal

Answer: C) SvelteKit


Q14. What is typically used with Express.js to render React apps on the server?

·        A) Babel

·        B) ReactDOMServer

·        C) Vue CLI

·        D) Prisma

Answer: B) ReactDOMServer


Q15. Which rendering approach is best for frequently updated, real-time dashboards?

·        A) Static site generation

·        B) Client-side rendering

·        C) Server-side rendering only

·        D) SSR without hydration

Answer: B) Client-side rendering

 

 

QUESTION NO. 18

🎯 CSS box-shadow – MCQs with Answers


🧩 Section 1: Basics of box-shadow


Q1. What is the correct CSS syntax for applying a box shadow?

·        A) box-shadow: 5px 10px blue;

·        B) box-shadow: 5px 10px 8px red;

·        C) shadow-box: 5px 10px red;

·        D) box-shadow: blue 5px 10px;

Answer: B) box-shadow: 5px 10px 8px red;


Q2. In the declaration box-shadow: 5px 5px 10px black;, what does the first 5px represent?

·        A) Vertical offset

·        B) Blur radius

·        C) Horizontal offset

·        D) Spread distance

Answer: C) Horizontal offset


Q3. In the same declaration, what does the second 5px represent?

·        A) Blur radius

·        B) Vertical offset

·        C) Spread radius

·        D) Border width

Answer: B) Vertical offset


Q4. What does the third value in box-shadow: 5px 5px 10px black; define?

·        A) Horizontal offset

·        B) Shadow color

·        C) Blur radius

·        D) Shadow spread

Answer: C) Blur radius


Q5. Which keyword is used to create an inset shadow instead of an outer shadow?

·        A) inner

·        B) inside

·        C) inset

·        D) shadow-in

Answer: C) inset


🧪 Section 2: Advanced Usage


Q6. What effect does a negative horizontal offset have in box-shadow?

·        A) Shadow is drawn to the bottom

·        B) Shadow is drawn to the left

·        C) Shadow is removed

·        D) Shadow is blurred

Answer: B) Shadow is drawn to the left


Q7. How can multiple box shadows be applied to a single element?

·        A) Only one shadow is allowed

·        B) Use commas to separate multiple shadows

·        C) Use box-shadow-2

·        D) Write shadows in separate declarations

Answer: B) Use commas to separate multiple shadows


Q8. What does the spread radius in box-shadow affect?

·        A) The color brightness

·        B) The shadow offset

·        C) The size of the shadow

·        D) The opacity of the element

Answer: C) The size of the shadow


Q9. What happens if the blur radius is set to 0 in a box shadow?

·        A) The shadow is sharp with no blur

·        B) The shadow is not rendered

·        C) The shadow becomes transparent

·        D) The element gets blurry

Answer: A) The shadow is sharp with no blur


Q10. Which of the following correctly defines a shadow with 10px blur, 3px spread, and blue color?

·        A) box-shadow: 0 0 10px 3px blue;

·        B) box-shadow: 10px blue 3px;

·        C) shadow: blue 0 0 3px 10px;

·        D) box-shadow: 10px 3px 0px blue;

Answer: A) box-shadow: 0 0 10px 3px blue;


Bonus: Real-World Application


Q11. Which shadow creates a glow around the element?

·        A) box-shadow: 0 0 15px red;

·        B) box-shadow: 10px 10px red;

·        C) box-shadow: inset 10px 10px red;

·        D) box-shadow: -10px 0px red;

Answer: A) box-shadow: 0 0 15px red;


Q12. Which of the following does not affect the appearance of a box shadow?

·        A) Shadow color

·        B) Blur radius

·        C) Border-radius

·        D) Spread distance

Answer: C) Border-radius
(It affects the shape of the box, but not the shadow's basic rendering logic.)

 

 

QUESTION NO 19:

Increasing Space Between Border and Content in CSS


🧩 Section 1: Basic Understanding


Q1. Which CSS property is used to increase the space between the border and the content of an element?

·        A) margin

·        B) padding

·        C) border-spacing

·        D) line-height

Answer: B) padding


Q2. What is the difference between padding and margin in CSS?

·        A) Padding is space outside the border; margin is inside

·        B) Padding is between content and border; margin is space outside the border

·        C) Both mean the same

·        D) Padding adds color; margin does not

Answer: B) Padding is between content and border; margin is space outside the border


Q3. What will padding: 20px; do to a div?

·        A) Add 20px space around the entire element

·        B) Add 20px space between elements

·        C) Add 20px space between the content and the border on all sides

·        D) Add 20px to the border width

Answer: C) Add 20px space between the content and the border on all sides


Q4. Which of the following properties does not affect the space between border and content?

·        A) padding

·        B) border-width

·        C) padding-top

·        D) padding-left

Answer: B) border-width


Q5. What will this CSS rule do? padding: 10px 20px;

·        A) Adds 10px left and right, 20px top and bottom

·        B) Adds 10px top & bottom, 20px left & right

·        C) Adds 10px on top only

·        D) Sets padding only to the left side

Answer: B) Adds 10px top & bottom, 20px left & right


⚙️ Section 2: Practical Use


Q6. To add 30px of space only at the top between the content and the border, which rule is correct?

·        A) margin-top: 30px;

·        B) border-top: 30px;

·        C) padding-top: 30px;

·        D) line-height: 30px;

Answer: C) padding-top: 30px;


Q7. What does the CSS padding: 5px 10px 15px 20px; mean?

·        A) Applies 5px padding to all sides

·        B) Applies 5px top, 10px right, 15px bottom, 20px left

·        C) Applies 20px top, 15px right, 10px bottom, 5px left

·        D) Adds 10px to left and right only

Answer: B) Applies 5px top, 10px right, 15px bottom, 20px left


Q8. Which of the following will increase the space between content and border only horizontally?

·        A) padding-left: 15px; padding-right: 15px;

·        B) margin-left: 15px;

·        C) padding-top: 15px;

·        D) border-spacing: 15px;

Answer: A) padding-left: 15px; padding-right: 15px;


Q9. Which shorthand padding value sets top = 10px, right = 20px, bottom = 30px, and left = 40px?

·        A) padding: 10px 20px 30px;

·        B) padding: 10px 20px 30px 40px;

·        C) padding: 10px 40px;

·        D) padding: 10px 20px 40px 30px;

Answer: B) padding: 10px 20px 30px 40px;


Q10. What happens if box-sizing: border-box; is set on an element with padding?

·        A) Padding is added outside the width

·        B) Padding increases total size

·        C) Padding is included within the specified width

·        D) Padding is ignored

Answer: C) Padding is included within the specified width

 

 

QUESTION NO. 20


1. Which of the following is primarily used for testing RESTful APIs?

A. Selenium
B. Postman
C. JUnit
D. Jenkins

Answer: B. Postman


2. Which of the following tools allows you to write test scripts in JavaScript for REST API testing?

A. SoapUI
B. Postman
C. Swagger UI
D. REST Assured

Answer: B. Postman


3. What is the main feature of REST Assured?

A. UI automation
B. Continuous Integration
C. Testing REST APIs in Java
D. Cloud deployment

Answer: C. Testing REST APIs in Java


4. Which tool provides both SOAP and REST API testing capabilities?

A. Postman
B. REST Assured
C. SoapUI
D. Newman

Answer: C. SoapUI


5. What is Newman in the context of API testing?

A. A debugger for APIs
B. A Postman command-line companion
C. An IDE for writing APIs
D. A deployment tool

Answer: B. A Postman command-line companion


6. Which of the following tools is most suitable for automated API documentation and testing?

A. Swagger
B. Git
C. Postman
D. Jenkins

Answer: A. Swagger


7. What does Swagger use to describe the structure of REST APIs?

A. WSDL
B. YAML or JSON
C. HTML
D. XML

Answer: B. YAML or JSON


8. Which of the following is NOT an API testing tool?

A. Karate
B. Postman
C. JMeter
D. Selenium

Answer: D. Selenium


9. Which tool is best for load testing REST APIs?

A. JMeter
B. Swagger
C. Newman
D. Jenkins

Answer: A. JMeter


10. What type of tests can you write in Postman using JavaScript?

A. Unit tests
B. Pre-request scripts and test assertions
C. Load tests
D. UI tests

Answer: B. Pre-request scripts and test assertions

 

 

QUESTION NO. 21

🔹 SQL and NoSQL MCQs


1. Which of the following is a relational database?

A. MongoDB
B. Cassandra
C. MySQL
D. Redis

Answer: C. MySQL


2. What does SQL stand for?

A. Structured Query Language
B. Simple Query Language
C. Sequential Query Logic
D. Structured Question List

Answer: A. Structured Query Language


3. Which of the following is a NoSQL database?

A. PostgreSQL
B. Oracle
C. MongoDB
D. SQLite

Answer: C. MongoDB


4. NoSQL databases are best suited for:

A. Structured data only
B. Fixed schema systems
C. Unstructured or semi-structured data
D. Financial transactions

Answer: C. Unstructured or semi-structured data


5. In SQL databases, data is stored in:

A. Collections
B. Documents
C. Tables
D. Key-value pairs

Answer: C. Tables


6. Which of the following is a document-based NoSQL database?

A. Redis
B. Cassandra
C. MongoDB
D. Neo4j

Answer: C. MongoDB


7. Which of the following supports ACID properties best?

A. MongoDB
B. Cassandra
C. MySQL
D. Couchbase

Answer: C. MySQL


8. What type of NoSQL database is Redis?

A. Document store
B. Key-value store
C. Column store
D. Graph store

Answer: B. Key-value store


9. Which of the following is a graph database?

A. Neo4j
B. Redis
C. SQLite
D. Firebase

Answer: A. Neo4j


10. A major advantage of NoSQL over SQL is:

A. Strong consistency
B. Fixed schema
C. Scalability and flexibility
D. Complex joins support

Answer: C. Scalability and flexibility

 

 

QUESTION NO. 22

🧪 Fundamentals of Unit Testing

1.     Which concept refers to testing individual units/components in isolation?
A. Integration testing
B. System testing
C. Unit testing
D. Acceptance testing

2.     Unit tests are usually written by:
A. Test manager
B. End users
C. Developers
D. Project sponsors

3.     A good unit test should be:
A. Slow
B. Fast
C. Complex
D. Dependent on environment

4.     Unit tests should ideally:
A. Depend on external APIs
B. Require a real database
C. Mock external dependencies
D. Run only manually

5.     A test that fails when the code is correct is called a:
A. Regression
B. Pass
C. False negative
D. Smoke test


Test Case Design

6.     Which phase defines conditions for test execution?
A. Implementation
B. Test specification
C. Deployment
D. Refactoring

7.     A unit test usually covers:
A. Application deployment
B. A single method or function
C. End-to-end workflow
D. Performance optimizations

8.     Boundary value testing is useful for:
A. Static pages
B. Edge conditions or limits
C. UI rendering
D. Document layout

9.     Test fixtures are used to:
A. Clean up database
B. Set up known state before tests
C. Deploy code
D. Monitor system logs

10.  Which test checks internal code behavior?
A. System test
B. Acceptance test
C. White‑box test
D. Black‑box test


📦 Testing Frameworks and Tools

11.  JUnit is used for:
A. Performance testing
B. Web UI testing
C. Java unit testing
D. API deployment

12.  In Python, the built‑in unittest module follows the:
A. T‑Test framework
B. G‑Test framework
C. xUnit framework
D. REST architecture

13.  In JavaScript, Jest is commonly used for:
A. RESTful services
B. Database tuning
C. Unit testing and mocking
D. Network configuration

14.  In C#, NUnit is an example of:
A. Static analysis tool
B. Code coverage tool
C. Unit test framework
D. Continuous integration server

15.  What does “assertEquals(expected, actual)” do in many testing frameworks?
A. Ignores test result
B. Compares output with expected
C. Comments out code
D. Generates documentation


🚧 Mocks, Stubs, and Fakes

16.  A stub is used to:
A. Replace test runner
B. Generate reports
C. Return fixed results for dependencies
D. Provide UI control

17.  A mock mainly:
A. Logs performance metrics
B. Verifies calls and expectations
C. Replaces database clean-up
D. Sets environment variables

18.  A fake is:
A. A full-blown replacement
B. Simpler but realistic implementation
C. A trap in code
D. A UI test harness

19.  In Python’s unittest.mock, “patch” is used to:
A. Fix bugs
B. Update modules
C. Replace objects/functions temporarily
D. Create databases

20.  Which is NOT a mock library?
A. Mockito
B. Postman
C. unittest.mock
D. Sinon


🔁 Test-Driven Development (TDD)

21.  The TDD cycle is:
A. Deploy → code → test
B. Red → Green → Refactor
C. Design → code → test
D. Test → code → deploy

22.  In TDD, “Red” means:
A. All tests passed
B. Tests have syntax errors
C. New tests failing
D. Code coverage high

23.  “Green” in TDD indicates:
A. Tests failing
B. Errors in framework
C. All tests passing with minimal code
D. Deprecated features

24.  Refactoring phase in TDD is to:
A. Delete tests
B. Improve code quality
C. Change requirements
D. Ignore errors

25.  TDD encourages:
A. Throwing exceptions freely
B. Writing tests before code
C. Manual QA only
D. No documentation


📈 Code Coverage

26.  Code coverage measures:
A. UI responsiveness
B. Percentage of code executed during testing
C. Number of test cases
D. Number of developers

27.  Which metric counts executed lines over total lines?
A. Statement coverage
B. Path coverage
C. Line coverage
D. Mutation coverage

28.  100% code coverage guarantees:
A. Perfect code
B. No bugs
C. Only that lines were executed
D. All edge cases tested

29.  Which shows coverage for decision outcomes?
A. Line coverage
B. Branch coverage
C. Statement coverage
D. Error coverage

30.  Which tool is used for Java code coverage?
A. Jenkins
B. JUnit
C. JaCoCo
D. Postman


📌 Best Practices

31.  Unit tests should be:
A. Dependent on OS
B. Repeatable and deterministic
C. Following execution order
D. Random in behavior

32.  Good test names are:
A. Random
B. Descriptive and meaningful
C. Gibberish
D. Extremely long sentences

33.  Tests should avoid:
A. Clear assertions
B. Small fixtures
C. Multiple responsibilities in one test
D. Isolation

34.  Tests should run:
A. Only on weekends
B. As part of continuous integration
C. After deployment
D. Offline only

35.  Tests should:
A. Depend on network latency
B. Require user input
C. Run unattended
D. Always show UI


🧱 Exception and Error Handling

36.  Testing exception behavior involves:
A. Ignoring exceptions
B. Asserting that exceptions are thrown
C. Logging only
D. Skipping on errors

37.  “assertThrows” asserts:
A. A method passed
B. No errors
C. An exception is thrown
D. Method is async

38.  Which scenario should be covered?
A. Happy path only
B. Invalid inputs and errors
C. UI refresh
D. Style guides

39.  Negative tests are:
A. Not allowed
B. Tests for incorrect inputs or failures
C. UI tests
D. Performance load tests

40.  For null input tests:
A. Skip coverage
B. Use assertions or exception checks
C. Ignore validation
D. Depend on default values


🧠 Design Insights

41.  Unit testing supports:
A. Faster deployments only
B. Better code modularity/design
C. UI refresh rate
D. Network bandwidth

42.  Loose coupling in code helps because:
A. Tests run slower
B. Code is monolithic
C. Dependencies can be easily mocked
D. Forces UI testing

43.  Dependency Injection helps to:
A. Enable UI features
B. Reduce coverage
C. Make mocking easier
D. Replace database deployment

44.  Pure functions are:
A. Dependent on global state
B. Hard to test
C. Easier to test
D. Unsupported by frameworks

45.  Which design hinder testing?
A. Modular classes
B. Tight coupling with static calls
C. DI containers
D. Service abstractions


🧩 Organizing Tests

46.  Unit tests should be grouped by:
A. Author name
B. Execution time
C. Functionality or module
D. Random order

47.  Often test files share suffix:
A. .js
B. .java
C. Test, Spec, or Should
D. .tmp

48.  A test suite typically:
A. Is deployed to production
B. Groups related tests together
C. Contains no assertions
D. Is manually run only

49.  A test runner:
A. Writes code
B. Sends emails
C. Executes tests and reports results
D. Alters production data

50.  Continuous Integration (CI) triggers tests:
A. After deploy
B. After lunch break
C. On code commit or pull request
D. Only at release time


⚙️ Integration with CI/CD

51.  Unit tests help by:
A. Writing documentation
B. Early bug detection
C. UI styling
D. Client billing

52.  Fast unit tests help CI because:
A. They require manual steps
B. They fail often
C. They provide quick feedback
D. They bypass tests

53.  Failing unit tests should:
A. Be ignored
B. Be postponed
C. Fail CI build immediately
D. Continue deployment

54.  Code coverage can be tracked:
A. In Excel
B. CentOS
C. With CI tools and plugins
D. Only in production

55.  Calling external APIs in tests:
A. Improves performance
B. Reduces reliability
C. Should be mocked for isolation
D. Only allowed in production


🧪 Advanced Topics

56.  Parameterized tests allow:
A. Multiple frameworks
B. UI testing only
C. Tests with multiple inputs easily
D. Code coverage reduction

57.  Data-driven tests read inputs from:
A. UI
B. CSV, JSON, or spreadsheets
C. Logs
D. Hard-coded globals

58.  Mutation testing introduces small code faults to:
A. Break builds
B. Check test suite quality
C. Deploy faster
D. Provide metrics to users

59.  Integration vs unit tests:
A. Unit tests test chains of services
B. Integration tests test interactions between units
C. Integration tests ignore databases
D. Unit tests require production servers

60.  What tests database logic in isolation?
A. API tests
B. UI tests
C. Unit tests with mocked repositories
D. Regression tests


🔧 Language-Specific Patterns

61.  In Java, @BeforeEach runs:
A. After tests
B. Before each test method
C. Before class load
D. Only once per class

62.  In JUnit, @AfterEach is:
A. Before all tests
B. Cleanup after each test
C. Before execute main
D. Not used

63.  In Python pytest, tests start with:
A. fun_
B. check_
C. test_
D. unit_

64.  In pytest, @pytest.fixture is used for:
A. Cleaning logs
B. Deploying code
C. Reusing setup across tests
D. Performance tuning

65.  In Jest, mocking functions uses:
A. describe()
B. afterAll()
C. jest.fn() or jest.mock()
D. beforeEach()


📝 Naming and Maintenance

66.  Good test names reflect:
A. Function complexity
B. Random code
C. Given‑When‑Then style
D. Author initials

67.  Test names shouldn’t include:
A. Description
B. Purpose
C. Implementation details
D. Edge case info

68.  When code changes, tests should:
A. Be deleted
B. Be deprecated
C. Be updated/refactored
D. Fail intentionally

69.  Refactoring tests ensures:
A. No assertions
B. Code coverage drops
C. Clarity and maintainability
D. Slower execution

70.  Tests should not test:
A. Public APIs
B. Business logic
C. Internal private code (unless via API)
D. Calculation methods


🛠️ Tools & Ecosystem

71.  Which integrates code coverage into CI?
A. Slack
B. Excel
C. SonarQube
D. MySQL

72.  Mock MVC in Spring supports:
A. UI tests only
B. Controller layer testing
C. Database migration
D. Authentication

73.  In front‑end React, Enzyme is used to:
A. Test databases
B. Style pages
C. Render and test components in isolation
D. Manage routing

74.  For .NET, Visual Studio has built‑in:
A. Database tools only
B. Unit test runners
C. REST frameworks
D. CI/CD pipelines

75.  Jest coverage reports show:
A. Page layout
B. API latency
C. Which lines/functions are covered
D. Server uptime


⚠️ Troubleshooting Tests

76.  If a unit test is flaky, you should:
A. Delete it
B. Make it slower
C. Fix nondeterminism
D. Ignore it

77.  Time-based waits in unit tests:
A. Increase reliability
B. Reduce variability
C. Cause nondeterminism/flakiness
D. Simplify mocks

78.  Long test suite duration:
A. Improves CI
B. Encourages batching
C. Requires optimization or splitting
D. Is acceptable

79.  Ordering tests by dependency:
A. Improves isolation
B. Helps mocking
C. Creates fragile suites
D. Simplifies naming

80.  Parallel running of unit tests:
A. Increases state sharing
B. Causes high coupling
C. Speeds CI builds if tests are isolated
D. Always fails


🏁 Integration with Other Testing Types

81.  Acceptance tests are written by:
A. End users
B. QA or product owners
C. Developers only
D. System admins

82.  Regression tests ensure:
A. Only new features
B. No breaking of existing behavior
C. UI rendering
D. Load distribution

83.  Smoke tests are:
A. Full unit suites
B. Quick checks of essential functionality
C. Load tests only
D. End-user scripts

84.  API contract tests verify:
A. Only UI
B. Input/output schema stability
C. Memory usage
D. Network latency

85.  Can mocks be used in integration tests?
A. Never
B. Only for UI
C. Yes, but with caution
D. MIssing repositories


🧠 Testing Practices & Philosophy

86.  Code reviews complement unit tests by:
A. Replacing coverage
B. Minimizing commits
C. Catching logic flaws and gaps
D. Automating runs

87.  Over-mocking can:
A. Simplify code
B. Eliminate flakiness
C. Make tests brittle and less realistic
D. Increase performance

88.  Testing only public interface helps:
A. Speed
B. Complexity
C. Allow internal code refactoring without breakage
D. Maintain private logic

89.  Testing private methods:
A. Is ideal
B. Should replace public tests
C. Usually discouraged—test via public behavior
D. Is mandatory

90.  A unit test should not rely on:
A. Mocks
B. Virtual calls
C. Production environment resources
D. Simulators


💡 Modern Practices & Metrics

91.  Mutation testing helps measure:
A. UI coverage
B. Test quality thoroughly
C. API latency
D. Code deployment speed

92.  Test quality is about:
A. Number of tests
B. Code coverage only
C. Assertions built into tests
D. Random test generation

93.  Static analysis tools detect:
A. Runtime behavior
B. Potential code issues before running tests
C. UI compatibility
D. Network errors

94.  BDD (Behavior‑Driven Development) style tests use:
A. Random assertions
B. Given‑When‑Then syntax
C. SQL queries
D. UI scripts

95.  Mocking vs spying:
A. No difference
B. Both avoid behavior tracking
C. Mocks set expectations, spies verify invocation
D. Only spies fail tests


📚 Developer Productivity

96.  Running tests locally before commit:
A. Slows CI
B. Increases conflicts
C. Prevents failing builds
D. Is optional

97.  Fast feedback loops are achieved by:
A. Using real servers
B. Running small unit tests frequently
C. Ignoring tests
D. UI automation

98.  Tests should be:
A. Unique and redundant
B. Randomly scattered
C. Independent and isolated
D. Interdependent

99.  To reduce test flakiness:
A. Hard‑code timestamps
B. Use global state
C. Seed random generators or mock time
D. Increase delays

100.                   A well‑written unit test provides:
A. UI coverage only
B. Clear documentation, regression safety, and design feedback
C. Random code execution
D. Only edge-case tests

 

 

QUESTION NO. 23

🔎 Integration Testing Fundamentals (1–15)

1.     **What is the primary goal of integration testing?**
A) To validate user requirements
B) To assess system performance
C) To test individual components in isolation
D) To ensure components work together as expected

2.     **Integration testing is also known as _____?**
A) Integration and Testing
B) Abbreviated I&T
C) Specialist integration tester
D) Both A and B

3.     **Integration testing is performed at which test level?**
A) Unit testing
B) System testing
C) Acceptance testing
D) Integration testing

4.     **What is the objective of integration testing?**
A) Test modules individually
B) Validate user expectations
C) Ensure module interfaces function correctly
D) Assess system performance
Answer: C

5.     **Who is typically responsible for integration testing?**
A) Developers
B) Testers
C) Specialist integration testers
D) Both A and C

6.     **Which of the following is NOT a type of integration testing?**
A) Top-Down Testing
B) Bottom-Up Testing
C) Big Bang Testing
D) Regression Testing

7.     **In Big Bang integration testing, when are modules combined?**
A) Incrementally
B) One at a time
C) All at once
D) Only after system testing

8.     **Which challenge is common in Big Bang testing?**
A) Fewer tests required
B) High cost
C) Hard to isolate defects
D) Slow execution

9.     **Incremental integration testing does what?**
A) Tests all modules at once
B) Skips foundational stability
C) Tests modules in small groups over multiple phases
D) Avoids using stubs/drivers

10.  **Which approach tests top modules first?**
A) Bottom-Up
B) Big Bang
C) Functional
D) Top-Down

11.  **Which integration approach begins with low-level modules?**
A) Top-Down
B) Mixed
C) Big Bang
D) Bottom-Up

12.  **Sandwich testing is a combination of?**
A) Unit + system testing
B) Top-Down + Big Bang
C) Bottom-Up + system testing
D) Top-Down + Bottom-Up

13.  **Which uses both stubs and drivers?**
A) Systems testing
B) Top-Down only
C) Bottom-Up only
D) Sandwich testing

14.  **A stub simulates which module?**
A) Higher-level modules
B) Lower-level modules
C) Same-level modules
D) External services

15.  **A driver simulates which module?**
A) Lower-level modules
B) Higher-level modules
C) Middleware
D) Test environment


🧠 Integration Techniques & Strategies (16–30)

16.  Which type tests data flow between integrated modules?
A) Regression testing
B) Non-incremental
C) Functional integration testing
D) Stress testing.

17.  What document is most useful during integration testing?
A) Test Plan
B) Module spec
C) System requirements
D) Interface Design Document

18.  High dependency between modules indicates:
A) Good design
B) Minimal interactions
C) Reusability
D) Poor design

19.  How many broad types of integration testing are there?
A) 5
B) 2 (incremental and non‑incremental)
C) 3
D) 4

20.  Which integration pattern exists besides top‑down & bottom‑up?
A) Backbone integration
B) Layer integration
C) Client‑server integration
D) All of the above

21.  Which integration testing helps isolate defects early?
A) Big Bang
B) Incremental
C) Manual only
D) None above

22.  Which approach reduces stubbing efforts?
A) Top‑Down only
B) Foreign testing
C) Big Bang
D) Bottom‑Up

23.  Which is easiest to debug?
A) Big Bang
B) Unit test
C) Top‑Down
D) Incremental testing

24.  Which helps test without ready modules?
A) Regression
B) Stress
C) Stubs and drivers use
D) UI testing

25.  Integration testing is done after:
A) System testing
B) Acceptance testing
C) Unit testing
D) Unit testing

26.  Integration testing differs from unit testing by focusing on:
A) Code coverage
B) Interfaces and communication
C) Performance
D) UI features
Answer: B

27.  Interfaces between components should match the:
A) Business spec
B) Test case
C) Interface Design Document
D) QA checklist
Answer: C

28.  What does functional integration test?
A) Performance only
B) UI only
C) Integration points and data exchange
D) Database only

29.  Risky-hardest integration testing focuses on:
A) Performance
B) Most critical integration paths
C) UI only
D) Documentation
Answer: B

30.  Integration testing is broader than unit but narrower than:
A) Regression testing
B) Acceptance testing
C) System testing


🛠 Tools & Real-World Practices (31–45)

31.  What framework helps integrate Spring with JUnit for integration testing?
A) Mockito
B) SpringJUnit4ClassRunner
C) TestNG
D) RestAssured
Answer: B

32.  To inject Spring-managed beans into integration tests, we use:
A) @Mock
B) @BeforeEach
C) @Autowired / @Resource
D) @TimeOut
Answer: C

33.  What listener handles @Transactional support in Spring tests?
A) DependencyInjectionTestExecutionListener
B) DirtiesContextTestExecutionListener
C) TransactionalTestExecutionListener
D) ContextLoaderListener
Answer: C

34.  A real-world integration test usually does NOT mock:
A) Database
B) External credit-card service
C) Logging
D) The system under test’s real dependencies

35.  Which tool is commonly used for API-level integration testing?
A) JMeter
B) Selenium
C) Postman
D) Cypress

36.  Containers like Docker or TestContainers are helpful for:
A) Unit tests only
B) Logging only
C) Replicating external services in integration tests

37.  Which kind of integration testing involves multiple systems but not necessarily full end-to-end?
A) Unit testing
B) Regression testing
C) Narrow integration tests
D) Performance testing

38.  Integration tests often run:
A) Faster than unit tests
B) Without external dependencies
C) Only in development
D) Longer and require configuration of multiple modules

39.  Clear separation of unit vs integration tests helps avoid:
A) Faster CI
B) Test flakiness and confusion
C) Higher coverage
D) Manual setup

40.  Mocking is commonly avoided in integration tests if:
A) Dependencies are stable
B) Real interactions are needed
C) Speed is required
D) Isolation is desired

41.  Good integration tests help validate:
A) Unit coverage
B) UI behavior
C) Data flows across modules/services
D) UI navigation

42.  Which reddit user said “integration test starts where unit testing ends”?
A) random
B) dev forum
C) QA lead
D) Software tester

43.  Testing a DAO connecting to a real DB is:
A) Unit test
B) UI test
C) Integration test
D) Regression test

44.  Using Mockito extensively inside integration tests may actually make them into:
A) Regression tests
B) Unit tests
C) Integration tests
D) Mock-heavy tests

45.  Spies vs mocks: mocks set expectations; spies:
A) Do the same
B) Are identical
C) Log test names
D) Verify invocation

 

 

 

QUESTION NO .24

🧠 Basic Recursion Concepts (1–10)

  1. What is recursion?
    A) A loop structure
    B) A pointer
    C) A function calling itself
    D) A class definition
    Answer: C
  2. Every recursive function must have:
    A) A loop
    B) A return value
    C) A base condition
    D) An increment operator
    Answer: C
  3. What happens if the base condition in a recursive function is not met?
    A) The function exits normally
    B) Compilation error
    C) Infinite recursion / Stack overflow
    D) It loops back
    Answer: C
  4. What is the maximum depth of recursion mainly limited by?
    A) Code size
    B) CPU speed
    C) System stack size
    D) Number of variables
    Answer: C
  5. Which of the following problems is best suited for recursion?
    A) Calculating factorial
    B) Tree traversal
    C) Tower of Hanoi
    D) All of the above
    Answer: D
  6. Which data structure is used internally by recursion?
    A) Queue
    B) Linked List
    C) Stack
    D) Tree
    Answer: C
  7. What does the return statement do in a recursive function?
    A) Terminates the program
    B) Pauses execution
    C) Returns control to the previous function call
    D) Continues the loop
    Answer: C
  8. In tail recursion, the recursive call is:
    A) Inside a loop
    B) The last operation performed in the function
    C) Followed by arithmetic
    D) Never used
    Answer: B
  9. Which one is NOT an advantage of recursion?
    A) Simpler code
    B) Elegant solution
    C) Efficient memory usage
    D) Direct mapping to divide & conquer
    Answer: C
  10. What does the following function compute?

python

CopyEdit

def foo(n):

    if n == 0:

        return 1

    else:

        return n * foo(n - 1)

A) Fibonacci
B) Sum of digits
C) Factorial
D) Square of a number
Answer: C


🔁 Recursion vs Iteration (11–15)

  1. Which is generally more memory-efficient?
    A) Recursion
    B) Iteration
    C) Both are equal
    D) Depends on language
    Answer: B
  2. Which approach is preferred for solving the Fibonacci series for performance?
    A) Iterative
    B) Recursive
    C) Linked list
    D) Object-oriented
    Answer: A
  3. Recursion uses more memory because:
    A) Code is larger
    B) Variables are global
    C) Each call is added to the call stack
    D) Looping takes time
    Answer: C
  4. Which is easier to debug and trace?
    A) Recursion
    B) Iteration
    C) Recursion with print
    D) Compiled code
    Answer: B
  5. Recursive functions may lead to stack overflow because:
    A) Functions are too long
    B) Variables are undefined
    C) Too many function calls without base case
    D) Wrong data type
    Answer: C

Intermediate/Code Tracing (16–25)

  1. How many times will this function be called?

python

CopyEdit

def count(n):

    if n == 0:

        return

    count(n - 1)

    print(n)

count(3)

A) 1
B) 3
C) 4
D) Infinite
Answer: C

  1. What does this print?

python

CopyEdit

def func(x):

    if x <= 0:

        return 0

    return x + func(x - 1)

print(func(3))

A) 0
B) 6
C) 3
D) 6
Answer: D

  1. Which of the following is NOT a recursive problem?
    A) Merge Sort
    B) DFS
    C) Binary Tree Traversal
    D) Linear Search in Array
    Answer: D
  2. Time complexity of naive recursive Fibonacci function is:
    A) O(n)
    B) O(log n)
    C) O(2ⁿ)
    D) O(n²)
    Answer: C
  3. The recurrence relation for the recursive factorial function is:
    A) F(n) = F(n+1)
    B) F(n) = n * F(n-1)
    C) F(n) = n + F(n+1)
    D) F(n) = n - F(n-1)
    Answer: B
  4. What is the base case in this function?

python

CopyEdit

def recur(n):

    if n <= 1:

        return 1

    return n * recur(n - 1)

A) n == 0
B) n <= 1
C) n == -1
D) None
Answer: B

  1. What’s printed by this?

python

CopyEdit

def test(n):

    if n > 0:

        test(n - 1)

        print(n, end=' ')

test(3)

A) 3 2 1
B) 1 2 3
C) 0 1 2
D) 3 2 1 0
Answer: B

  1. What happens with infinite recursion?
    A) CPU usage drops
    B) Nothing
    C) Stack Overflow
    D) Code loops forever
    Answer: C
  2. Which algorithm heavily uses recursion?
    A) Bubble Sort
    B) Linear Search
    C) Merge Sort
    D) Counting Sort
    Answer: C
  3. Tail recursion can be optimized by the compiler to:
    A) Use more memory
    B) Avoid additional stack frames
    C) Increase runtime
    D) Create infinite loops
    Answer: B

⚙️ Advanced & Conceptual (26–30)

  1. Which language does NOT optimize tail recursion well?
    A) C
    B) Haskell
    C) Python
    D) Lisp
    Answer: C
  2. Which recursion type makes a single call in each execution?
    A) Linear recursion
    B) Binary recursion
    C) Multiple recursion
    D) Mutual recursion
    Answer: A
  3. A function calling another function which calls the first is called:
    A) Deep recursion
    B) Indirect recursion
    C) Mutual recursion
    D) Nested recursion
    Answer: C
  4. A recursive function with two calls per level is:
    A) Linear
    B) Mutual
    C) Binary recursion
    D) Direct recursion
    Answer: C
  5. In terms of memory and performance, recursion is usually:
    A) Better than iteration
    B) Worse than iteration
    C) Equal to iteration
    D) Ignored in programming
    Answer: B

 

 

QUESTION NO. 25

🧠 Basic Function Concepts (1–10)

  1. A function is best described as:
    A) A loop that repeats actions
    B) A block of code that modifies variables globally
    C) A block of code that performs a specific task and can return a value
    D) A data type
    Answer: C
  2. Every function must return a value.
    A) True
    B) False
    Answer: B (Some functions return nothing, e.g.,
    void in C)
  3. In mathematics, a function maps:
    A) Multiple outputs to one input
    B) Each input to exactly one output
    C) One output to multiple inputs
    D) Inputs to all outputs
    Answer: B
  4. A pure function is one that:
    A) Changes global state
    B) Reads and writes files
    C) Has no side effects and always returns the same output for the same input
    D) Depends on random values
    Answer: C
  5. What is a side effect in a function?
    A) The result it returns
    B) Any modification of external state
    C) Syntax errors
    D) Variable initialization
    Answer: B
  6. In Python, a function can return multiple values using:
    A) Arrays
    B) Tuples
    C) Dictionaries only
    D) Lists only
    Answer: B
  7. What is the output of this code?

python

CopyEdit

def f():

    return

print(f())

A) 0
B) Error
C) None
D) Null
Answer: C

  1. A function that calls itself is called a:
    A) Looping function
    B) Generator
    C) Iterative function
    D) Recursive function
    Answer: D
  2. Which of the following is NOT true about functions?
    A) They help in code reusability
    B) They improve code structure
    C) They always require parameters
    D) They may return a value
    Answer: C
  3. A function with the same name but different parameters is called:
    A) Recursive
    B) Anonymous
    C) Overloaded
    D) Encapsulated
    Answer: C

🔁 Function Behavior & Scope (11–20)

  1. Functions help with:
    A) Repetition of code only
    B) Modularity and reuse
    C) CPU efficiency
    D) Making code longer
    Answer: B
  2. What keyword is used to define a function in Python?
    A) fun
    B) function
    C) define
    D) def
    Answer: D
  3. What is the scope of a variable defined inside a function?
    A) Global
    B) Local to that function
    C) Class-level
    D) Static
    Answer: B
  4. Which of the following causes a function to stop executing?
    A) continue
    B) break
    C) return
    D) pass
    Answer: C
  5. In programming, the function parameters are also known as:
    A) Return types
    B) Arguments
    C) Constants
    D) Loops
    Answer: B
  6. Which of these is true about default parameters?
    A) They are required for every function
    B) They provide default values when arguments are missing
    C) They must be first in the argument list
    D) They are used only in classes
    Answer: B
  7. Which function does not return any value?
    A) Return function
    B) Void function
    C) Main function
    D) Static function
    Answer: B
  8. In mathematics, which of the following is not a function?
    A) f(x) = x + 1
    B) f(x) = x²
    C) f(x) = √x
    D) f(x) = ±√x
    Answer: D (multiple outputs for one input)
  9. In most languages, local variables in a function are created when:
    A) Program starts
    B) Function is called
    C) Program ends
    D) Variable is declared
    Answer: B
  10. What is an anonymous function in Python called?
    A) nameless
    B) private
    C) lambda
    D) void
    Answer: C

⚙️ Advanced Concepts (21–30)

  1. What is function composition?
    A) Writing multiple functions
    B) Breaking a function into smaller ones
    C) Combining functions where one’s output is another’s input
    D) Writing nested loops
    Answer: C
  2. Which of these can be used as a function return value?
    A) Single value
    B) Object
    C) List
    D) All of the above
    Answer: D
  3. Closures are functions that:
    A) Close the program
    B) Retain access to the outer scope in which they were created
    C) Return random values
    D) Have no name
    Answer: B
  4. In functional programming, functions are treated as:
    A) Instructions
    B) Control flow statements
    C) First-class citizens
    D) Variables
    Answer: C
  5. Which of the following is a higher-order function?
    A) A function that calls itself
    B) A function with many arguments
    C) A function that takes another function as input or returns one
    D) A very complex function
    Answer: C
  6. Which function prints its arguments without a newline in Python 3?
    A) printf
    B) write
    C) print(arg, end="")
    D) echo
    Answer: C
  7. What happens when a return is not used in a function?
    A) Returns None (in Python)
    B) Returns 0
    C) Causes an error
    D) Exits program
    Answer: A
  8. Recursion can be replaced with:
    A) Class
    B) Loop
    C) Iteration
    D) Import
    Answer: C
  9. A function can be assigned to a variable in which language?
    A) C
    B) Python
    C) Java
    D) None
    Answer: B
  10. Which of the following is NOT a characteristic of a function?
    A) Has a name (except anonymous)
    B) May take input
    C) Always modifies global state
    D) May return output
    Answer: C

 

QUESTION NO. 26

Redux & Core Concepts (1–25)

1.     What is Redux primarily used for?
A) Routing
B) Styling
C) Global state management

2.     Redux is based on which architecture?
A) MVC
B) Flux
C) MVVM
D) OOP
Answer: B) Flux

3.     What does Redux store contain?
A) Local component state
B) API responses
C) Application-wide state

4.     An action in Redux is:
A) A function that directly modifies state
B) A middleware
C) A plain JavaScript object describing a state change

5.     A reducer in Redux must be:
A) Impure
B) Stateful
C) Async
D) Pure function returning new state

6.     What does combineReducers() do?
A) Binds middleware
B) Combines multiple reducers into root reducer

7.     How do you dispatch an action?
A) getState()
B) subscribe()
C) dispatch()
D) connect()
Answer: C) dispatch()

8.     How do you access Redux state in React?
A) useState()
B) useContext()
C) useSelector()
D) useEffect()
Answer: C) useSelector()

9.     Which hook is used to dispatch in React-Redux?
A) useStore()
B) useDispatch()
C) useContext()
D) useReducer()
Answer: B) useDispatch()

10.  Action objects should include:
A) type only
B) payload only
C) type and payload

11.  Redux enforces state updates through:
A) Mutable operations
B) Immutable updates via pure reducers

12.  Redux’s data flow is:
A) Bidirectional
B) Event-driven
C) Unidirectional

13.  Redux store is created with:
A) createStore()
B) new Store()
C) configure()
D) initStore()
Answer: A) createStore()

14.  Redux DevTools supports:
A) State encryption
B) Time travel debugging

15.  Persisting Redux state across sessions is done with:
A) localStorage
B) redux-persist
C) API backend
D) cookies
Answer: B) redux-persist

16.  Using multiple useSelector inside one component is:
A) Not allowed
B) Possible and recommended
C) Only in class components
D) Causes errors
Answer: B) Possible and recommended

17.  Redux encourages a “single source of truth”:
A) False
B) True

18.  Selectors in Redux are used for:
A) Routing
B) Extracting or deriving state

19.  Middleware in Redux is used to:
A) Update UI
B) Manage routing
C) Handle asynchronous actions or side-effects

20.  Redux Thunk enables:
A) Multiple stores
B) Synchronous actions only
C) Action creators returning functions for async logic

21.  Redux Toolkit simplifies:
A) Local state only
B) Middleware setup only
C) Store setup and reducer logic

22.  Can Redux be used with frameworks other than React?
A) No
B) Net only
C) Yes — Angular, Vue, vanilla JS, etc.

23.  You should not put which in a reducer?
A) Computations
B) Combining logic
C) Async calls or side-effects

24.  What's an enhancer?
A) Subscriptions list
B) Function that wraps the store to extend behavior

25.  getState() returns:
A) Subscribers
B) Current state
C) Action queue
D) Reducer map
Answer: B) Current state


🌐 Context API, React Hooks & Alternatives (26–50)

26.  Context API + useContext() is best for:
A) Routing
B) Styling
C) Lightweight global or dependency-injected state

27.  React Context re-renders all consumers on updates unless:
A) State is shallow
B) Components use useMemo or selective context
C) State slices are memoized or isolated

28.  useMemo() is for:
A) Memoizing computed values
B) Stateful data
C) Subscriptions
D) Routing
Answer: A) Memoized computed values

29.  useCallback() is used to:
A) Memoize functions to prevent re-creations
B) Handle async logic
C) Subscribe to context
D) Update state
Answer: A) Memoize functions

30.  Which avoids deep mutation issues via proxy?
A) Context
B) Redux
C) MobX or Valtio

31.  Lightweight alternative that avoids context boilerplate:
A) React Query
B) Redux
C) Zustand

32.  Atomic state library with minimal API:
A) MobX
B) Redux
C) Jotai

33.  Library built on state machines for predictable workflows:
A) Redux
B) MobX
C) XState

34.  Use React Query (TanStack Query) for:
A) Local form state
B) Server-side data fetching and caching

35.  For global UI-loading state, prefer:
A) Context only
B) React Query
C) Zustand or Jotai

36.  Many devs avoid Redux and use Context + hooks instead, with occasional React Query — True?
Answer: True

37.  Which library is faster than React Context per benchmarks?
A) Redux
B) Zustand and Jotai

38.  For form or URL parameter state, which is often sufficient?
A) Jotai
B) Alice
C) React Query and custom hooks

39.  Many companies still list Redux in job descriptions despite smaller libs gaining traction — True?
Answer: True

40.  Decision flow: learn Context Redux Zustand or Recoil — suggested approach?
Answer: Yes

41.  For small projects, which is often overkill?
A) Vuex
B) Context only
C) Redux

42.  If state updates in context re-renders whole subtree, use:
A) Redux only
B) React Query
C) Zustand to avoid cascading rerenders  

 

 

 

QUESTION NO. 29

Single Responsibility Principle – MCQs

Basic Understanding

1.     What does the Single Responsibility Principle (SRP) state?
A) A class should inherit from only one parent
B) A class should perform only one job or responsibility
C) A class should not use other classes
D) A class should be written only once
Answer: B
Explanation: SRP means a class should have only one reason to change.

2.     SRP is part of which design principle group?
A) KISS
B) DRY
C) SOLID
D) YAGNI
Answer: C

3.     A violation of SRP might result in:
A) More performance
B) Smaller classes
C) Tightly coupled code
D) Faster testing
Answer: C

4.     According to SRP, what is a "reason to change"?
A) A distinct responsibility or behavior
B) A runtime error
C) A user interface update
D) A code refactor
Answer: A

5.     Which of the following best violates SRP?
A) A logger class logging to multiple destinations
B) A User class handling authentication and user profile logic
C) A controller calling a service
D) A service delegating to a repository
Answer: B


Code Design Applications

6.     If a class has multiple responsibilities, it becomes harder to:
A) Compile
B) Deploy
C) Test and maintain
D) Load in memory
Answer: C

7.     How should SRP be enforced in a codebase?
A) By adding comments
B) By splitting classes with unrelated responsibilities
C) By keeping all logic in a single file
D) By using inheritance
Answer: B

8.     What is the main benefit of applying SRP?
A) Faster execution
B) Reduced memory usage
C) Improved code maintainability and readability
D) Automatic debugging
Answer: C

9.     Which design pattern encourages SRP?
A) Singleton
B) Factory
C) Facade
D) Composite
Answer: C
Explanation: Facade simplifies interaction by separating concerns.

10.  In SRP, separation of concerns means:
A) Using different file types
B) Each module/class handles only one aspect of functionality
C) Modules are reused in all projects
D) Only one class is used
Answer: B


Real-World & Practical Scenarios

11.  Which class design most adheres to SRP?
A) OrderManager class that processes payment and sends emails
B) UserService that handles login and renders views
C) Logger class that only logs messages
D) AdminService that authenticates users and manages roles
Answer: C

12.  When you split responsibilities into multiple classes, you get:
A) Less code reuse
B) Loosely coupled components
C) More complex inheritance
D) Slower application
Answer: B

13.  SRP helps in:
A) Hiding implementation details
B) Increasing polymorphism
C) Reducing merge conflicts and regression bugs
D) Speeding up compilation
Answer: C

14.  What is an anti-pattern that commonly violates SRP?
A) Factory pattern
B) Fat controller
C) God object
D) Command pattern
Answer: C

15.  A class that validates input, logs errors, and saves to database violates SRP because:
A) It uses too much memory
B) It’s too small
C) It has too many unrelated reasons to change
D) It has no methods
Answer: C


Advanced & Architecture

16.  SRP promotes:
A) Synchronous operations
B) Separation of concerns
C) Code duplication
D) Class inheritance
Answer: B

17.  How does SRP affect unit testing?
A) Slows down testing
B) Increases test size
C) Simplifies and isolates tests
D) Requires mocking everything
Answer: C

18.  Which is a common sign that a class violates SRP?
A) It is used by two modules
B) It changes frequently for unrelated reasons
C) It is part of a module
D) It has one method
Answer: B

19.  Applying SRP might result in:
A) Monolithic applications
B) More, but smaller, focused classes
C) A single large class
D) More bugs
Answer: B

20.  Which statement is true about SRP?
A) It slows down development
B) It’s only for back-end systems
C) It is relevant in both object-oriented and functional programming
D) Only frontend developers need it
Answer: C

 

QUESTION NO.  30

 console.log(this) in JavaScript

1. Global Context (Browser)

Q1: What does console.log(this) output in the global scope (non-strict mode) in a browser?

javascript
CopyEdit
console.log(this);

A) undefined
B) window
C) global
D) null
Answer: B) window


2. Global Context (Node.js)

Q2: What does console.log(this) output at the top level in a Node.js module?

javascript
CopyEdit
console.log(this);

A) {}
B) global
C) window
D) undefined
Answer: A) {}


3. Inside a Regular Function (Non-strict mode)

Q3: What is logged here?

javascript
CopyEdit
function test() {
  console.log(this);
}
test();

A) undefined
B) window
C) global
D) test
Answer: B) window (in browser, non-strict mode)


4. Inside a Regular Function (Strict Mode)

Q4: What is logged here?

javascript
CopyEdit
'use strict';
function test() {
  console.log(this);
}
test();

A) window
B) global
C) undefined
D) {}
Answer: C) undefined


5. Inside an Arrow Function

Q5: What does this log?

javascript
CopyEdit
const obj = {
  method: () => {
    console.log(this);
  }
};
obj.method();

A) obj
B) undefined
C) window
D) The global object
Answer: D) The global object (window in browser)


6. Arrow Function Inside a Method

Q6: What is logged?

javascript
CopyEdit
const obj = {
  name: 'JS',
  log: function() {
    const arrow = () => {
      console.log(this);
    };
    arrow();
  }
};
obj.log();

A) undefined
B) window
C) obj
D) arrow
Answer: C) obj


7. In a DOM event listener

Q7: What is this inside a traditional function used in an event listener?

javascript
CopyEdit
button.addEventListener('click', function() {
  console.log(this);
});

A) window
B) button element
C) document
D) undefined
Answer: B) button element


8. In an arrow function inside event listener

Q8: What is this in the arrow function below?

javascript
CopyEdit
button.addEventListener('click', () => {
  console.log(this);
});

A) button
B) document
C) undefined
D) Lexically scoped this (e.g., window)
Answer: D) Lexically scoped this


9. Inside a class method

Q9: What is logged?

javascript
CopyEdit
class MyClass {
  myMethod() {
    console.log(this);
  }
}
new MyClass().myMethod();

A) undefined
B) MyClass instance
C) window
D) Function
Answer: B) MyClass instance


10. Method extraction

Q10: What happens here?

javascript
CopyEdit
const obj = {
  greet() {
    console.log(this);
  }
};
const greet = obj.greet;
greet();

A) obj
B) undefined
C) window
D) null
Answer: C) window (non-strict mode)


🧠 More Complex Contexts

11. Arrow inside setTimeout

javascript
CopyEdit
const obj = {
  val: 42,
  logLater() {
    setTimeout(() => {
      console.log(this.val);
    }, 100);
  }
};
obj.logLater();

Answer: 42 – Arrow function retains lexical this


12. Regular function in setTimeout

javascript
CopyEdit
const obj = {
  val: 42,
  logLater() {
    setTimeout(function() {
      console.log(this.val);
    }, 100);
  }
};
obj.logLater();

Answer: undefined – Regular function’s this is global object


13. With bind()

javascript
CopyEdit
function sayHi() {
  console.log(this.name);
}
const user = { name: 'Alice' };
const boundSayHi = sayHi.bind(user);
boundSayHi();

Answer: 'Alice'bind() sets this permanently


14. Using call()

javascript
CopyEdit
function greet() {
  console.log(this.lang);
}
greet.call({ lang: 'JS' });

Answer: 'JS'


15. Object method called from another object

javascript
CopyEdit
const a = {
  val: 1,
  show() {
    console.log(this.val);
  }
};
const b = { val: 2, show: a.show };
b.show();

Answer: 2this is dynamic, based on the caller (b)


🧪 Tricky or Gotcha Cases

16. Nested functions (non-arrow)

javascript
CopyEdit
const obj = {
  outer: function() {
    function inner() {
      console.log(this);
    }
    inner();
  }
};
obj.outer();

Answer: windowinner() is regular function


17. With IIFE

javascript
CopyEdit
(function() {
  console.log(this);
})();

Answer: window (in browser, non-strict)


18. Class static method

javascript
CopyEdit
class Example {
  static log() {
    console.log(this);
  }
}
Example.log();

Answer: Example class itself


19. Class instance arrow function

javascript
CopyEdit
class A {
  constructor() {
    this.say = () => console.log(this);
  }
}
const a = new A();
a.say();

Answer: a – arrow function binds this to instance


20. Reassigning arrow function

javascript
CopyEdit
const obj = {
  name: 'Obj',
  say: () => console.log(this.name)
};
obj.say();

Answer: undefinedthis is not obj, but global

 

 

QUESTION NO 27

 models.py in Django

🔹 Basic Concepts

1. What is the purpose of models.py in a Django app?
A) Define URL routes
B) Define HTML templates
C) Define the data structure using models
D) Define view logic
Answer: C


2. Which base class must every Django model inherit from?
A) django.core.Model
B) django.db.DBModel
C) BaseModel
D) models.Model
Answer: D


3. Which of these defines a CharField in Django models?
A) CharField(max_length=50)
B) models.CharField(max_length=50)
C) models.Text(max_length=50)
D) CharField(50)
Answer: B


4. What field is commonly used for primary key in Django?
A) models.PrimaryField()
B) models.KeyField()
C) models.AutoField()
D) models.IntField()
Answer: C


5. If no primary_key=True is specified, Django automatically creates:
A) id = models.CharField(...)
B) uid = models.UUIDField(...)
C) pk = models.PrimaryKey(...)
D) id = models.AutoField(primary_key=True)
Answer: D


🔹 Fields and Data Types

6. Which field type is best for storing large text content?
A) models.CharField()
B) models.TextField()
C) models.StringField()
D) models.BigCharField()
Answer: B


7. What does blank=True mean in a Django model field?
A) Field must be blank
B) Field will always be NULL
C) Field is allowed to be empty in forms
D) It applies to the database only
Answer: C


8. What does null=True mean in Django models?
A) Field cannot be left empty
B) Field must be a string
C) Field must be NULL in Python
D) Field can store NULL in the database
Answer: D


9. What does unique=True do in a model field?
A) Accepts duplicate entries
B) Ensures value is never NULL
C) Prevents duplicate entries
D) Makes field a foreign key
Answer: C


10. Which field should be used to store a date and time?
A) models.DateField()
B) models.DateTimeField()
C) models.TimeStampField()
D) models.CharField()
Answer: B


🔹 Relationships

11. What is used to define a one-to-many relationship?
A) models.OneToOneField()
B) models.ManyToManyField()
C) models.ForeignKey()
D) models.RelatedField()
Answer: C


12. Which argument is required in a ForeignKey field?
A) related_model
B) target_model
C) on_delete
D) relationship
Answer: C


13. What does on_delete=models.CASCADE do?
A) Raises an error on delete
B) Deletes related objects
C) Ignores delete operation
D) Logs the deletion
Answer: B


14. What relationship is created by ManyToManyField?
A) One-to-one
B) One-to-many
C) Many-to-many
D) Foreign key with unique=True
Answer: C


15. Which is valid for a one-to-one relationship?
A) models.ForeignKey(unique=True)
B) models.OneField()
C) models.OneToOneField()
D) models.CharField(primary_key=True)
Answer: C


🔹 Model Methods & Meta Options

16. Which method defines string representation of a model?
A) __title__()
B) __repr__()
C) __str__()
D) __name__()
Answer: C


17. What does class Meta: define inside a model?
A) Model metadata like ordering, db_table, verbose_name
B) HTML form options
C) URL configurations
D) Admin permissions
Answer: A


18. What is the use of ordering = ['name'] in Meta?
A) Orders forms
B) Orders migrations
C) Applies default ordering to querysets
D) Sorts models alphabetically
Answer: C


19. Which method saves a model instance?
A) update()
B) save()
C) create()
D) store()
Answer: B


20. Which method deletes a model instance?
A) clear()
B) delete()
C) destroy()
D) remove()
Answer: B


🔹 Advanced Usage

21. To override save behavior, which method should be customized?
A) create()
B) make()
C) save()
D) store()
Answer: C


22. What is related_name used for in a ForeignKey?
A) Validation
B) Enforces constraints
C) Specifies reverse relation name
D) Changes table name
Answer: C


23. How can you define a default value for a model field?
A) set_default()
B) field.default = value
C) models.Field(default=value)
D) Using default=value in field definition
Answer: D


24. Which Django command creates database tables from models?
A) python manage.py startapp
B) python manage.py initdb
C) python manage.py migrate
D) python manage.py build
Answer: C


25. Which command reflects changes in models.py before migration?
A) python manage.py reload
B) python manage.py makemigrations
C) python manage.py resetdb
D) python manage.py flush
Answer: B

 

 

QUESTION NO 29.

Does normalization deal with combining tables or splitting tables.

 

Answer:

Does normalization deal with combining tables or splitting tables.

 

Explanation:

Normalization is the process of organizing data in a database to:

·        Reduce redundancy (duplicate data)

·        Improve data integrity

·        Make the database more efficient to update and maintain


🔹 What Does It Typically Involve?

·        Splitting large tables into smaller, related tables.

·        Creating relationships (often via foreign keys) between those tables.

·        Ensuring that each table has a single purpose or theme.


🔸 Example:

Suppose you have a table like this:

StudentID

StudentName

CourseName

1

Alice

Math

1

Alice

English

This design repeats Alice's name, violating normalization rules.

After normalization (splitting):

Students Table:

StudentID

StudentName

1

Alice

Courses Table:

CourseID

CourseName

101

Math

102

English

Enrollments Table (many-to-many):

StudentID

CourseID

1

101

1

102


🔚 Final Answer:

Normalization deals with splitting tables to eliminate redundancy and ensure data consistency.

 

 

QUESTION NO 32

MCQs on Embedded Systems

🔹 Basic Concepts

1. What is an embedded system?
A) A system with a keyboard and display
B) A general-purpose computer
C) A system designed to perform a specific task
D) A gaming console
Answer: C


2. Which of the following is a common feature of embedded systems?
A) High memory and processing power
B) General-purpose usage
C) Real-time operation
D) Ability to run multiple OSes
Answer: C


3. An airbag system in a car is an example of:
A) Soft real-time system
B) Hard real-time system
C) General-purpose system
D) Multi-user system
Answer: B


4. Which microcontroller family is widely used in embedded systems?
A) Intel i9
B) AMD Ryzen
C) 8051
D) Nvidia RTX
Answer: C


5. The brain of an embedded system is usually a:
A) Modem
B) RAM
C) Microcontroller
D) Display unit
Answer: C


🔹 Hardware Components

6. What does RAM do in an embedded system?
A) Stores permanent data
B) Stores temporary data
C) Controls input/output
D) Displays output
Answer: B


7. EEPROM in embedded systems is used for:
A) Non-volatile storage
B) Displaying text
C) Temporary buffers
D) High-speed computing
Answer: A


8. GPIO stands for:
A) Global Peripheral Input Output
B) General Purpose Input Output
C) General Program Interface Output
D) Ground Pulse Input Output
Answer: B


9. Which component provides the clock signal in embedded systems?
A) ALU
B) RAM
C) Crystal Oscillator
D) GPIO
Answer: C


10. What is the function of a watchdog timer?
A) To power off the system
B) To reset the system if it hangs
C) To check temperature
D) To manage memory
Answer: B


🔹 Software and OS Concepts

11. Which of the following is an embedded operating system?
A) Ubuntu
B) Windows
C) Fedora
D) FreeRTOS
Answer: D


12. RTOS stands for:
A) Remote Time Operating System
B) Real-Time Operating System
C) Reduced Task OS
D) Runtime Timing OS
Answer: B


13. A soft real-time system:
A) Cannot miss any deadline
B) Will crash on deadline miss
C) Can tolerate occasional deadline misses
D) Doesn't use any timers
Answer: C


14. Which programming language is most common for embedded systems?
A) Python
B) Java
C) C
D) PHP
Answer: C


15. The process of burning code into microcontroller flash memory is called:
A) Booting
B) Debugging
C) Testing
D) Flashing
Answer: D


🔹 Examples and Applications

16. Which of the following is NOT an embedded system?
A) Laptop
B) Microwave
C) Digital Watch
D) Automatic Washing Machine
Answer: A


17. Which of the following is typically considered a real-time embedded system?
A) Email server
B) Weather website
C) Pacemaker
D) Printer spooler
Answer: C


18. Which application would most likely use a soft real-time system?
A) Anti-lock braking system
B) Missile guidance
C) Video streaming
D) Fire alarm
Answer: C


19. Embedded systems are usually:
A) Standalone only
B) Networked only
C) Mobile only
D) Either standalone or networked
Answer: D


20. A mobile phone is considered an embedded system. Why?
A) It has only one application
B) It runs on AC power
C) It integrates hardware and software for specific functionality
D) It doesn't require an OS
Answer: C


🔹 Advanced Topics

21. Interrupts in embedded systems are used for:
A) Booting
B) Handling asynchronous events
C) Storing data
D) Writing to flash
Answer: B


22. Which bus is most commonly used for internal communication in microcontrollers?
A) PCI
B) USB
C) I²C / SPI / UART
D) HDMI
Answer: C


23. DMA stands for:
A) Dual Memory Address
B) Direct Memory Access
C) Data Memory Allocation
D) Device Micro Access
Answer: B


24. Power consumption in embedded systems is important because:
A) It improves screen resolution
B) It increases clock speed
C) They often run on battery
D) It helps cooling fans
Answer: C


25. Which of these is a common debugging tool in embedded systems?
A) Selenium
B) JTAG
C) Git
D) Visual Studio Code
Answer: B

QUESTION NO 33

 Real-Time Operating Systems (RTOS)


🔹 Basic Concepts

1. What is a Real-Time Operating System (RTOS)?
A) A system that executes only background tasks
B) A system that runs slowly but accurately
C) A system that guarantees correct output
D) A system that responds within a defined time constraint
Answer: D


2. Which of the following is NOT a feature of RTOS?
A) Deterministic behavior
B) Multitasking
C) Delays in task switching
D) Priority-based scheduling
Answer: C


3. RTOS is primarily used in:
A) Gaming laptops
B) Word processors
C) Embedded systems
D) Web browsers
Answer: C


**4. A hard real-time system:
A) Can tolerate missed deadlines
B) Prioritizes memory over timing
C) Must meet deadlines strictly
D) Never processes in real-time
Answer: C


**5. A soft real-time system:
A) Will crash on missing a deadline
B) Can occasionally miss deadlines
C) Does not use scheduling
D) Is slower than batch systems
Answer: B


🔹 Scheduling & Tasks

6. RTOS uses which scheduling algorithm most commonly?
A) Round-robin
B) Priority-based preemptive scheduling
C) First-come-first-serve
D) Batch scheduling
Answer: B


7. What is context switching in RTOS?
A) Switching from low to high frequency
B) Saving and loading task states during task switches
C) Changing user roles
D) Logging task history
Answer: B


8. Which task gets the CPU in preemptive scheduling?
A) The longest task
B) The background task
C) The highest priority ready task
D) The one that started first
Answer: C


9. What happens if a low-priority task holds a resource needed by a high-priority task?
A) Starvation
B) Priority inversion
C) Preemption
D) Context switch
Answer: B


10. Which mechanism helps avoid priority inversion?
A) Memory sharing
B) Priority inheritance
C) Deadlock avoidance
D) Mutex lock
Answer: B


🔹 RTOS Features

11. Which of these is critical for RTOS?
A) GUI support
B) Internet access
C) Predictable timing behavior
D) Rich libraries
Answer: C


12. RTOS typically supports:
A) Batch processing
B) Just one process at a time
C) Multitasking and inter-process communication (IPC)
D) Graphic-intensive applications
Answer: C


13. What does an RTOS kernel manage?
A) Only files
B) Database connections
C) Tasks, scheduling, and resources
D) HTML rendering
Answer: C


14. Which type of memory is often used for storing RTOS kernels?
A) RAM
B) HDD
C) ROM or Flash
D) Cache
Answer: C


15. The tick timer in an RTOS is used for:
A) UI animations
B) Generating periodic interrupts for task switching
C) Creating power supply
D) Network handling
Answer: B


🔹 RTOS APIs & Mechanisms

16. What is a semaphore used for in RTOS?
A) Speeding up tasks
B) Synchronization and resource sharing
C) Increasing memory
D) Scheduling priorities
Answer: B


17. What is a mutex in RTOS?
A) A multi-CPU tool
B) A mutual exclusion mechanism for tasks
C) Task scheduler
D) Hardware driver
Answer: B


18. Which function is used to start the RTOS kernel?
A) runOS()
B) start_task()
C) start_scheduler()
D) boot()
Answer: C (e.g., in FreeRTOS)


19. An ISR (Interrupt Service Routine) in RTOS:
A) Runs in background
B) Always has lower priority
C) Responds quickly to hardware interrupts
D) Can be delayed
Answer: C


20. Which of the following cannot be called directly from ISR?
A) xTaskCreate()
B) xQueueSendFromISR()
C) portYIELD_FROM_ISR()
D) vTaskDelay()
Answer: D


🔹 Examples and Applications

21. Which of the following is an RTOS?
A) Linux Mint
B) FreeRTOS
C) Windows 11
D) MacOS
Answer: B


22. Which is a commercial RTOS?
A) VxWorks
B) Ubuntu
C) Android
D) Raspbian
Answer: A


23. Which of the following devices uses RTOS?
A) Laptop
B) Airbag control unit
C) Smart TV
D) Web server
Answer: B


24. FreeRTOS is:
A) A web server
B) An open-source real-time operating system
C) Only used in smartphones
D) Based on Windows
Answer: B


25. RTOS is essential in which of the following fields?
A) Blogging
B) Video editing
C) Aerospace and medical systems
D) Spreadsheet analysis
Answer: C


🔹 Advanced Topics

26. RTOS latency refers to:
A) Network speed
B) Time between interrupt and task response
C) Clock drift
D) Task priority
Answer: B


27. Which best describes deterministic behavior in RTOS?
A) Same result every time
B) Predictable response time for operations
C) Delays for resource sharing
D) Random output
Answer: B


28. What is task starvation?
A) When a task ends early
B) When a task doesn’t use memory
C) When low-priority tasks never get CPU time
D) A resource leak
Answer: C


29. What is task stack overflow in RTOS?
A) Stack shared between tasks
B) Unused memory
C) When a task exceeds its stack allocation
D) Thread count increase
Answer: C


30. Which of the following can reduce RTOS performance?
A) Preemption
B) Determinism
C) Improper task priority assignment
D) Semaphore use
Answer: C

QUESTION NO 34

 Reducing Load in Microservices Architecture


🔹 Core Concepts

1. What is one of the primary reasons for high load in a microservice?
A) Frequent deployments
B) Lack of documentation
C) Too many synchronous calls
D) Using REST APIs
Answer: C


2. Which pattern helps reduce direct communication between microservices?
A) Singleton
B) Observer
C) API Gateway
D) Client-Side Load Balancing
Answer: C


3. What strategy helps avoid overloading a microservice by rejecting excess requests?
A) Retry pattern
B) Rate limiting
C) Service discovery
D) Circuit breaker
Answer: B


4. Which pattern is used to prevent cascading failures under load?
A) Retry pattern
B) Circuit breaker pattern
C) Anti-corruption layer
D) Singleton pattern
Answer: B


5. Caching in microservices is used to:
A) Increase CPU usage
B) Reduce repeated database calls
C) Increase traffic
D) Persist data forever
Answer: B


🔹 Scalability and Load Distribution

6. Which type of scaling involves creating more instances of a service?
A) Vertical scaling
B) Horizontal partitioning
C) Horizontal scaling
D) Load shifting
Answer: C


7. What does a load balancer do in a microservice setup?
A) Encrypts traffic
B) Distributes traffic across instances
C) Runs database backups
D) Sends alerts
Answer: B


8. In Kubernetes, which component ensures service scaling under load?
A) NodePort
B) Scheduler
C) Horizontal Pod Autoscaler (HPA)
D) Sidecar
Answer: C


9. Which tool is commonly used for service discovery to handle load better?
A) Docker
B) Consul
C) GitLab
D) Apache Spark
Answer: B


10. Which practice reduces load on a microservice by delaying non-critical work?
A) Rate limiting
B) Asynchronous processing
C) Load shedding
D) Batch queries
Answer: B


🔹 Data and Messaging Patterns

11. Which message broker can help reduce synchronous load between services?
A) MySQL
B) Redis
C) RabbitMQ
D) Prometheus
Answer: C


12. The benefit of event-driven architecture is:
A) Slower processing
B) More coupling
C) Loose coupling and reduced direct load
D) More data duplication
Answer: C


13. What is a sidecar in service mesh used for?
A) Logging only
B) Offloading infrastructure tasks like traffic routing and retries
C) UI rendering
D) API versioning
Answer: B


14. Why would a microservice use a queue like Kafka?
A) To store backups
B) To handle spikes in traffic asynchronously
C) For security
D) To call APIs faster
Answer: B


15. What’s the role of a CDN (Content Delivery Network) in reducing load?
A) API rate limiting
B) Serving static content closer to users
C) Encrypting data
D) Improving write latency
Answer: B


🔹 Best Practices & Tools

16. What does bulkheading help with in microservices?
A) Load balancing
B) Isolating failures to prevent full system overload
C) Removing dead code
D) Creating replicas
Answer: B


17. Which database pattern reduces the load by replicating data across services?
A) CQRS
B) Database sharding
C) Cache busting
D) Event storming
Answer: B


18. What happens in client-side load balancing?
A) Clients connect only to the master node
B) Client decides which service instance to call
C) Load is shifted to the browser
D) The server redirects the request
Answer: B


19. Which monitoring tool helps detect spikes in load before failures?
A) Git
B) Postman
C) Prometheus
D) ESLint
Answer: C


20. Which retry strategy helps reduce load on failing services?
A) Continuous retry
B) Exponential backoff
C) Constant retry
D) Retry loop
Answer: B

 

QUESTION NO 35.

Write once, run anywhere (choose either React Native, flutter, ionic, xamarin)

Correct answer: Flutter.

 

QUESTION NO 36

 API Versioning


🔹 Basics & Concepts

1. What is API versioning primarily used for?
A) Logging API calls
B) Making APIs public
C) Maintaining backward compatibility
D) Securing the API
Answer: C


2. Which of the following is NOT a method of API versioning?
A) URI versioning
B) Query parameter versioning
C) Header versioning
D) IP-based versioning
Answer: D


3. What is a major benefit of versioning your API?
A) It speeds up performance
B) It allows you to introduce breaking changes safely
C) It reduces the number of endpoints
D) It eliminates the need for documentation
Answer: B


4. Which is a commonly used format for URI versioning?
A) /api/data/
B) /api/v2/data/
C) /api/data/v=2
D) /v2-data/
Answer: B


5. What does v1 in /api/v1/products represent?
A) Version of the product
B) View name
C) API version
D) Product ID
Answer: C


🔹 Techniques & Implementation

6. What is one drawback of using URI versioning?
A) It's hard to implement
B) It breaks RESTful resource identification
C) It requires OAuth
D) It increases security risks
Answer: B


7. Which versioning strategy is most suitable for clients that frequently change their requirements?
A) Header versioning
B) URI versioning
C) Semantic URL
D) Unversioned endpoints
Answer: A


8. What HTTP header is commonly used for custom API versioning?
A) Content-Type
B) Authorization
C) Accept
D) Location
Answer: C


9. What is the main risk of not using API versioning?
A) More documentation
B) Breaking changes for existing clients
C) Lower memory usage
D) Duplicate endpoints
Answer: B


10. Which of these is an example of query parameter versioning?
A) /api/v1/users
B) /api/users?version=1
C) /api/users/v1/
D) /v1/api/users
Answer: B


🔹 Best Practices

11. Which versioning scheme uses dates in the version ID?
A) Date-based versioning
B) Semantic versioning
C) Header versioning
D) Linear versioning
Answer: A


12. Which of these is a recommended practice when deprecating an API version?
A) Delete immediately
B) Rename all endpoints
C) Provide a deprecation notice and sunset period
D) Disable access to all clients
Answer: C


13. In REST APIs, versioning is typically applied to:
A) Only POST requests
B) The entire API
C) One endpoint at a time
D) Database layer only
Answer: B


14. Semantic versioning typically uses which format?
A) v1.0a
B) 1.2-beta
C) MAJOR.MINOR.PATCH (e.g., 2.1.3)
D) /vOne
Answer: C


15. Which versioning strategy is least intrusive to the URI structure?
A) URI versioning
B) Query parameter
C) Header versioning
D) Custom MIME type
Answer: C


🔹 Advanced Topics

16. Why might you want to avoid too many versions of an API?
A) More users
B) Faster performance
C) Increased maintenance complexity
D) Better security
Answer: C


17. Which versioning approach is RESTful but may clutter the URL?
A) Header versioning
B) Semantic versioning
C) URI versioning
D) Versioning by hostname
Answer: C


18. What is the purpose of application/vnd.company.v2+json?
A) Custom domain name
B) Content negotiation using MIME type versioning
C) Logging format
D) JSON schema definition
Answer: B


19. Versioning by host means:
A) Subdomains represent different versions
B) All APIs are unversioned
C) You use query parameters only
D) REST is not used
Answer: A

Example: v1.api.example.com


20. Which versioning strategy offers the most flexibility for client-specific versions?
A) URI versioning
B) Header-based versioning
C) Query param versioning
D) No versioning
Answer: B

 

 

QUESTION NO 37

Key Functions of an API Gateway in Microservices


1. 🔁 Request Routing

·        Directs incoming client requests to the appropriate microservice.

·        Hides internal service structure from the client.

📌 Example: Routes /orders/123 to the OrderService.


2. 🔒 Authentication and Authorization

·        Verifies user identity (e.g., with JWT, OAuth2).

·        Ensures users only access permitted resources.


3. 📊 Rate Limiting and Throttling

·        Prevents service overload by limiting how many requests a client can make.


4. 🎛️ Load Balancing

·        Distributes requests across multiple instances of a service for performance and fault tolerance.


5. 🧹 Request/Response Transformation

·        Converts request formats, headers, or response structures between client and service.

·        Helps decouple clients from internal APIs.


6. 📦 Aggregation / Composition

·        Combines results from multiple services into a single response.

Useful in front-end apps to reduce the number of API calls.


7. 🚨 Logging, Monitoring, and Metrics

·        Captures performance and error logs for debugging and analysis.

·        Often integrates with tools like Prometheus, ELK, or Grafana.


8. 💥 Fault Tolerance

·        Implements retries, timeouts, circuit breakers, or fallback responses if a service fails.


Summary

🧠 The API Gateway acts as a front door to your microservice ecosystem, handling cross-cutting concerns like security, routing, load balancing, and more — simplifying client communication and improving system scalability and maintainability.


 

 API Gateway Functions in Microservices


🔹 Core Functions

1. What is the primary role of an API Gateway in microservices?
A) Hosting databases
B) Storing data
C) Routing client requests to the appropriate service
D) Monitoring servers
Answer: C


2. Which of the following is a key security function of an API Gateway?
A) DNS lookup
B) HTML parsing
C) Authentication and authorization
D) Compression
Answer: C


3. API Gateway acts as a:
A) Message broker
B) Single entry point for client requests
C) Database controller
D) Static file server
Answer: B


4. Which of the following is NOT typically handled by an API Gateway?
A) Logging
B) Service discovery
C) Data storage
D) Load balancing
Answer: C


5. API Gateway helps reduce:
A) Code complexity
B) The number of calls between client and services
C) HTML errors
D) The size of the database
Answer: B


🔹 Advanced Features

6. What is response aggregation in an API Gateway?
A) Combining responses from multiple services into one
B) Splitting a response into smaller parts
C) Encrypting the response
D) Logging API errors
Answer: A


7. Which protocol is commonly used for communication through an API Gateway?
A) FTP
B) SMTP
C) HTTP/HTTPS
D) SNMP
Answer: C


8. Why would an API Gateway implement rate limiting?
A) To increase database speed
B) To prevent abuse and reduce load
C) To allow unlimited access
D) To bypass authentication
Answer: B


9. What is the circuit breaker pattern used for in an API Gateway?
A) To shut down servers
B) To send email alerts
C) To stop requests to failing services temporarily
D) To encrypt API keys
Answer: C


10. Which of the following tools can act as an API Gateway?
A) PostgreSQL
B) Jenkins
C) Kong / NGINX / Amazon API Gateway
D) Redis
Answer: C


🔹 Microservice Integration

11. How does the API Gateway support scalability?
A) By compressing images
B) By distributing traffic to multiple service instances
C) By adding more RAM
D) By deleting logs
Answer: B


12. What is one disadvantage of using an API Gateway?
A) Decreased security
B) No logging capabilities
C) Single point of failure if not highly available
D) Loss of data
Answer: C


13. In microservices, an API Gateway enables:
A) Monolithic behavior
B) Serverless storage
C) Loose coupling between client and services
D) Client-side validation only
Answer: C


14. Which of the following can an API Gateway modify?
A) Java bytecode
B) Client-side HTML
C) Request and response headers
D) Service names
Answer: C


15. Which client-side problem does an API Gateway help solve?
A) Managing multiple service endpoints
B) CSS rendering
C) HTML validation
D) Caching browser history
Answer: A


🔹 Security & Performance

16. How does an API Gateway enhance security?
A) By reducing code duplication
B) By acting as a firewall for services
C) By deleting data automatically
D) By blocking IP addresses permanently
Answer: B


17. API Gateway supports which caching benefit?
A) Reduces repeated requests to microservices
B) Speeds up database joins
C) Increases disk usage
D) Reduces token generation
Answer: A


18. How can an API Gateway reduce network traffic?
A) By turning off logging
B) By splitting requests
C) Through response caching and request collapsing
D) By compressing JSON data only
Answer: C


19. If a service is temporarily down, how can an API Gateway help?
A) Delete that service
B) Return a fallback response
C) Retry endlessly
D) Redirect to login page
Answer: B


20. Which pattern ensures only authenticated users reach internal services?
A) Retry pattern
B) Gateway security filter
C) Load balancing
D) Data sync
Answer: B

 

 

QUESTION NO 38.

 Decreasing Workload in while/for Loops


🔹 Basic Concepts

1. What is one common way to reduce workload inside a for-loop?
A) Add nested loops
B) Use more global variables
C) Minimize work done inside the loop body
D) Increase loop iterations
Answer: C


2. Which of these can improve the efficiency of a loop?
A) Using expensive function calls inside the loop repeatedly
B) Caching repeated calculations outside the loop
C) Printing inside every iteration
D) Creating new objects in every iteration
Answer: B


3. What is loop unrolling?
A) Adding more loops inside
B) Expanding the loop body to reduce the number of iterations
C) Reducing loop variables
D) Using recursion instead of loops
Answer: B


4. Which data structure can decrease loop workload by providing faster access?
A) Linked list
B) Array
C) Hash map/dictionary
D) Stack
Answer: C


🔹 Optimization Techniques

5. Moving invariant code out of a loop means:
A) Running the same code every time
B) Calculating values that don’t change outside the loop
C) Changing the loop condition
D) Nesting loops inside
Answer: B


6. Which of the following can reduce workload in nested loops?
A) Increasing nested loop depth
B) Using a break statement when possible
C) Reducing nested iterations by better algorithm design
D) Ignoring the inner loop
Answer: C


7. What does "short-circuit evaluation" help with in loops?
A) Looping infinitely
B) Stopping evaluation early in logical expressions
C) Increasing workload
D) Sorting elements faster
Answer: B


8. Why should you avoid modifying the loop counter inside a for loop?
A) It’s good practice
B) It can cause unpredictable loop behavior and errors
C) It makes the loop faster
D) It simplifies code
Answer: B


🔹 Language-Specific Best Practices

9. In JavaScript, what’s more efficient in loops?
A) Using var inside the loop
B) Caching the array length outside the loop condition
C) Declaring new variables inside the loop
D) Using eval in each iteration
Answer: B


10. When processing large data sets in loops, what helps reduce memory usage?
A) Creating many temporary arrays inside loops
B) Using generators or lazy evaluation
C) Storing all intermediate results in arrays
D) Using recursion inside loops
Answer: B


11. Which of the following can reduce workload in Python loops?
A) Using list comprehensions instead of for loops
B) Using global variables
C) Using nested for loops indiscriminately
D) Creating new objects in every iteration
Answer: A


🔹 Algorithmic Improvements

12. To reduce the number of iterations, which technique can be used?
A) Increment by 1 only
B) Increment by steps larger than 1 when possible
C) Use while(true) loops
D) Remove loop conditions
Answer: B


13. Which sorting technique reduces workload when partially sorting data inside loops?
A) Bubble sort always
B) Using efficient sorts like quicksort or mergesort outside loops
C) Sorting inside every iteration
D) No sorting at all
Answer: B


14. Which method can avoid unnecessary iterations in a loop?
A) Looping over entire data always
B) Breaking early when a condition is met
C) Using nested loops for all tasks
D) Calling expensive functions inside the loop
Answer: B


🔹 Miscellaneous

15. Loop fusion means:
A) Splitting one loop into many
B) Combining multiple loops that iterate over the same range into one
C) Removing all loops
D) Adding nested loops
Answer: B


16. Why is using a while loop sometimes better than a for loop?
A) For readability only
B) When the number of iterations is not known upfront
C) It’s always faster
D) It uses less memory
Answer: B


17. Which is a disadvantage of excessive optimization inside loops?
A) Improved readability
B) Code becomes harder to maintain and understand
C) Faster runtime
D) Reduced CPU usage
Answer: B


18. What’s the effect of unnecessary I/O operations inside loops?
A) Faster execution
B) Significant slowdown due to waiting for I/O
C) No impact
D) Better memory usage
Answer: B


19. Using parallel processing to split loop workload is called:
A) Loop unrolling
B) Loop parallelization
C) Loop fusion
D) Loop hoisting
Answer: B


20. Which of the following can reduce loop workload in numeric computations?
A) Using integer division when possible
B) Using floating point for all calculations
C) Avoiding built-in math functions
D) Using nested loops for all tasks
Answer: A

 

 

 

QUESTION NO 39.

Output of 10+20+”30”

Answer

The output of the expression:

js

CopyEdit

10 + 20 + "30"

depends on how JavaScript evaluates it step-by-step.


Step-by-step evaluation:

  1. 10 + 2030 (number addition)
  2. 30 + "30""3030" (number + string results in string concatenation)

So, the final output is:

plaintext

CopyEdit

"3030"

 

QUESTION NO 40

Output of ya concept ya try catch and final

Answer

How try, catch, and finally work:

·        The try block contains code that might throw an error.

·        The catch block runs if an error occurs in the try.

·        The finally block runs always, regardless of whether an error was thrown or caught.


Example in JavaScript:

js
CopyEdit
function test() {
  try {
    console.log("Inside try");
    throw new Error("Error occurred!");
    console.log("This line is not executed");
  } catch (e) {
    console.log("Inside catch:", e.message);
    return "Returned from catch";
  } finally {
    console.log("Inside finally");
    // Even if we return here, finally executes before return
  }
}
 
console.log(test());

What happens here:

·        try starts and prints "Inside try".

·        Throws an error → jumps to catch.

·        catch prints "Inside catch: Error occurred!" and returns "Returned from catch".

·        Before returning, finally executes and prints "Inside finally".

·        The returned value "Returned from catch" is printed by the last console.log.


Output:

vbnet
CopyEdit
Inside try
Inside catch: Error occurred!
Inside finally
Returned from catch

Key points about finally:

·        It always runs, even if there's a return in try or catch.

·        If finally has a return statement, it overrides the return from try or catch.

 

QUESTION NO 41.

Concept of Modularity


1. What does modularity in software design refer to?
A) Combining all code into a single file
B) Dividing a program into separate, independent modules
C) Writing code without comments
D) Using global variables only
Answer: B


2. Which of the following is a main benefit of modularity?
A) Increased program size
B) Improved maintainability and readability
C) Decreased performance
D) More complex debugging
Answer: B


3. What is a module?
A) A variable
B) A function that never ends
C) A self-contained component with a specific functionality
D) An error in code
Answer: C


4. Modularity helps in:
A) Writing monolithic code
B) Ignoring code reuse
C) Facilitating code reuse and independent development
D) Making code dependent on each other
Answer: C


5. Which principle is closely related to modularity?
A) Single Responsibility Principle
B) Don’t Repeat Yourself
C) Both A and B
D) None of the above
Answer: C


6. How does modularity affect testing?
A) Makes testing harder
B) Enables unit testing of individual modules
C) Forces integration testing only
D) Testing is not affected
Answer: B


7. Which of the following is NOT a characteristic of a good module?
A) High cohesion
B) Low coupling
C) Large and complex
D) Encapsulated functionality
Answer: C


8. What does “low coupling” mean in modular design?
A) Modules depend heavily on each other
B) Modules have minimal dependencies on one another
C) Modules share many global variables
D) Modules cannot function independently
Answer: B


9. Which of these is an example of modular programming?
A) Writing all code in one file
B) Using functions and classes to separate concerns
C) Avoiding functions
D) Using global variables extensively
Answer: B


10. How does modularity impact collaboration in software development?
A) Makes teamwork difficult
B) Allows multiple developers to work independently on different modules
C) Causes frequent conflicts
D) Reduces code quality
Answer: B

 

QUESTION NO 42.

Can a table have multiple primary keys?

No, a table cannot have more than one primary key.


But then, how do you enforce uniqueness on multiple columns?

  • A table can have only one primary key, but that primary key can be composed of multiple columns.
  • This is called a composite primary key or compound primary key.

Example of composite primary key:

sql

CopyEdit

CREATE TABLE Orders (

  order_id INT,

  product_id INT,

  quantity INT,

  PRIMARY KEY (order_id, product_id)  -- composite key

);

Here, the combination of order_id and product_id must be unique.


Summary:

Question

Answer

Can a table have multiple primary keys?

No

Can a primary key consist of multiple columns?

Yes (composite primary key)

 

 

QUESTION NO 43

difference between upgrade and update

 

 Difference Between Upgrade and Update

Aspect

Update

Upgrade

Meaning

Applying minor fixes, patches, or improvements

Moving to a newer major version or edition

Scope

Usually small changes (bug fixes, security)

Significant changes (new features, architecture)

Example

Windows 10 version 21H1 → 21H2 (same major version)

Windows 10 → Windows 11

Frequency

Frequent and incremental

Less frequent, major step

Impact on functionality

Fixes existing functionality or improves performance

Adds new capabilities or changes functionality

Size

Small downloads

Large downloads or installations

Risk

Low risk

Higher risk, sometimes requires backups


Quick summary:

·        Update = small improvements or fixes within the same version.

·        Upgrade = major version jump or complete replacement with new features.


 

Difference Between Upgrade and Update


1. What is typically the main purpose of a software update?
A) To install a completely new version
B) To add major new features
C) To fix bugs and improve security
D) To uninstall old software
Answer: C


2. Which of the following best describes a software upgrade?
A) Small patch to fix issues
B) Moving to a newer major version with additional features
C) Changing system settings
D) Applying minor performance improvements
Answer: B


3. How does the size of an update usually compare to an upgrade?
A) Updates are larger than upgrades
B) Upgrades are larger than updates
C) Both are always the same size
D) Updates delete files, upgrades do not
Answer: B


4. Which process generally involves more risk and preparation?
A) Update
B) Upgrade
C) Neither involves risk
D) Both are equally risky
Answer: B


5. Updating software is usually:
A) Less frequent and more complex
B) More frequent and smaller in scope
C) Only done when hardware changes
D) A complete replacement of software
Answer: B


6. Which statement is true?
A) An update changes the software's major version number
B) An upgrade changes the software's major version number
C) Updates and upgrades are the same
D) Upgrades are always automatic, updates are manual
Answer: B


7. A security patch released to fix vulnerabilities is an example of:
A) Upgrade
B) Update
C) New installation
D) Downgrade
Answer: B


8. Switching from Windows 10 to Windows 11 is an example of:
A) Update
B) Upgrade
C) Patch
D) Hotfix
Answer: B


9. Which of the following is generally NOT a characteristic of an update?
A) Fixes bugs
B) Adds small improvements
C) Changes core architecture significantly
D) Improves security
Answer: C


10. When you apply an upgrade, you usually expect:
A) Minimal changes with bug fixes
B) New features and possibly changed user interface
C) No changes at all
D) Removal of all existing features
Answer: B

 

 

QUESTION NO 44

Which tool supports real-time collaboration in designing?

(a) Figma
(b) Adobe XD
(c) InVision
(d) Sketch


Correct answer: (a) Figma


Explanation:

  • Figma is well-known for its strong real-time multi-user collaboration capabilities where multiple designers can work simultaneously.
  • Adobe XD and InVision have some collaboration features but are not as seamless or real-time as Figma.
  • Sketch mainly relies on third-party plugins for collaboration and is primarily a desktop app.

 

QUESTION NO 45

  Function of JavaScript in Web Development


1. What is the primary role of JavaScript in web development?
A) Structure the webpage with elements
B) Style the webpage with colors and layouts
C) Add interactivity and dynamic behavior to webpages
D) Host the website on a server
Answer: C


2. Which of the following can JavaScript do on a webpage?
A) Modify HTML content dynamically
B) Respond to user events like clicks and keyboard input
C) Validate form data before submission
D) All of the above
Answer: D


3. JavaScript runs on the:
A) Server only
B) Client browser only
C) Both client browser and server (Node.js)
D) Database
Answer: C


4. Which JavaScript feature allows asynchronous loading of data without refreshing the page?
A) CSS
B) HTML
C) AJAX (Asynchronous JavaScript and XML)
D) SQL
Answer: C


5. Which of these is NOT a function of JavaScript in web development?
A) Creating animations
B) Handling user input
C) Sending data to a server
D) Designing webpage layout
Answer: D


6. How does JavaScript interact with HTML elements?
A) Through SQL queries
B) By using the Document Object Model (DOM)
C) By editing CSS files directly
D) Through FTP protocols
Answer: B


7. Which of these is a JavaScript method to select an HTML element by its ID?
A) getElementByClassName()
B) getElementById()
C) querySelectorAll()
D) createElement()
Answer: B


8. What is event handling in JavaScript?
A) Running the server
B) Styling elements
C) Responding to user actions like clicks or keypresses
D) Managing databases
Answer: C


9. Which keyword is used in JavaScript to define a function?
A) define
B) func
C) function
D) method
Answer: C


10. JavaScript can communicate with servers using:
A) FTP
B) HTTP requests (e.g., fetch API or XMLHttpRequest)
C) SMTP
D) TCP only
Answer: B

 

Share:

0 comments:

Post a Comment

Contact Us

SALEHE NJOHOLE MSIMBAZI CENTRE P.O.BOX 2428, DAR ES SALAAM, TANZANIA EAST AFRIKA. Call: 0692 127 931