Core Java and J2EE Concepts Quiz
0 Questions
1 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

Flashcards

Java String Comparison: "==" vs new String()

The == operator performs reference equality in Java, comparing if two strings are literally the same object in memory. The new String() creates a new object instance even if the literal value is identical, thus making s1 == s3 false. "abc" is a string literal and is treated as a unique object, hence s1 == s2 is true.

Java continue & break in Loops

The continue statement skips the current iteration of the loop and jumps to the next one. The break statement completely terminates the loop's execution. This code increments y and checks conditions. Even numbers are skipped (y % x == 0), and the loop breaks at y == 8. Only odd numbers less than 8 are printed.

Java Inheritance and Shadowing

In Java, inheritance follows the principle of "hiding" or "shadowing". The child class (B) inherits the parent class (A) but can declare member variables (like int a) with the same name. So, within the scope of class B, obj.a refers to B's a (20). However, because obj is declared as type A, only A's methods are accessible, hence a (10) is printed.

Reversing an Array in Java

The code iterates through an array, swapping each element with the one at the opposite end. The assignment arr[i] = arr[arr.length - 1 - i] basically flips the array around.

Signup and view all the flashcards

Java Interface Default Methods and Multiple Inheritance

Multiple inheritance is not directly supported in Java. Interfaces can have default methods, which are implemented by classes that implement that interface. Using X.super.print() explicitly calls the default method of interface X.

Signup and view all the flashcards

What is NOT a J2EE component?

AWT is a Java library for creating basic graphical user interfaces (GUIs) but is not a part of the J2EE architecture, which focuses on enterprise-level web applications. Java Servlet, JSP, and EJB are core components of J2EE.

Signup and view all the flashcards

Key Feature of Enterprise JavaBeans (EJB)

Enterprise JavaBeans (EJB) is a framework for developing server-side components that support distributed transactions, allowing multiple applications to work together across networks.

Signup and view all the flashcards

Purpose of JNDI in J2EE

JNDI (Java Naming and Directory Interface) is an API used in J2EE applications to look up and discover resources, such as databases, JMS queues, and EJBs, using a naming system. Essentially, it acts like a phone book for accessing objects within a J2EE application.

Signup and view all the flashcards

Role of web.xml in J2EE

The web.xml deployment descriptor in a J2EE web application is where you configure key aspects of your app, including mapping URLs to servlets, setting session timeout values, and defining security constraints. It's the central configuration file for your web application.

Signup and view all the flashcards

Servlet's primary function in J2EE

Servlets are Java programs that run on a web server and generate dynamic web content. They handle HTTP requests, process data, and send responses to clients, enabling interactive web applications.

Signup and view all the flashcards

Mapping Immutable Entities in Hibernate

To mark an entity as immutable in Hibernate, we use the @Immutable annotation. This ensures that Hibernate treats the entity as read-only and doesn't attempt to modify it.

Signup and view all the flashcards

Hibernate's @Fetch(FetchMode.SUBSELECT) annotation

The @Fetch(FetchMode.SUBSELECT) annotation tells Hibernate to fetch associated collections using a separate subquery for each entity. This helps optimize performance when there are many entities but reduces the need to join tables.

Signup and view all the flashcards

Hibernate's Second-Level Cache

The second-level cache in Hibernate acts as a shared cache for entities across sessions, improving performance by storing frequently accessed data. This enables all sessions to access the same cached data.

Signup and view all the flashcards

Hibernate's @version annotation

The @version annotation in Hibernate marks a specific field as a 'version' field, used for optimistic locking. When an entity is updated, Hibernate compares the version value to detect potential conflicts.

Signup and view all the flashcards

Hibernate's @NaturalId annotation

The @NaturalId annotation in Hibernate maps a natural business key (a field representing a unique identifier) to a unique constraint in the database. This helps maintain data integrity and ensure uniqueness based on real-world constraints.

Signup and view all the flashcards

Spring @Component Annotation

The @Component annotation is used to mark a class as a candidate for auto-detection by Spring's component scanning mechanism, making it a Spring-managed bean. This facilitates dependency injection and allows Spring to manage the lifecycle of your component.

Signup and view all the flashcards

Spring @Autowired Annotation

The @Autowired annotation in Spring is used to inject dependencies automatically by type. It allows Spring to find and inject the correct instance of a dependency into the annotated method parameter or field.

Signup and view all the flashcards

What is Spring Boot?

Spring Boot is a powerful tool for building Spring applications with minimal configuration. It provides auto-configuration, embedded servers, and CLI tools, making development much easier.

Signup and view all the flashcards

Spring @Transactional Annotation

The @Transactional annotation in Spring is used to mark a method as requiring transactional behavior. It instructs Spring to manage the transaction for that method, ensuring consistency and data integrity.

Signup and view all the flashcards

Defining Custom Scopes in Spring

Custom scopes in Spring allow you to control the lifecycle and visibility of your beans. You can extend the Scope interface to define your own custom scopes and register them with the Spring application context.

Signup and view all the flashcards

The Role of WSDL in SOAP Web Services

WSDL (Web Services Description Language) is used to describe the capabilities of a web service, including the operations it supports (e.g., methods, parameters), data types (e.g., XML schema), and how to communicate with it. Think of it as a contract that defines how to interact with the web service.

Signup and view all the flashcards

HTTP PUT in RESTful APIs

The HTTP method PUT is idempotent, meaning that multiple identical requests have the same effect as one. In RESTful APIs, it's typically used to update an existing resource, replacing it entirely with the data provided in the request body.

Signup and view all the flashcards

What is UDDI?

UDDI (Universal Description, Discovery, and Integration) is a registry where businesses can publish information about their web services, and other businesses can discover and use those services. It acts like a central directory for web services.

Signup and view all the flashcards

HATEOAS : REST API Principle

HATEOAS (Hypermedia As The Engine Of Application State) is a REST API design constraint, aiming for APIs that are self-documenting and discoverable. It means making APIs discoverable through links within the response, allowing clients to understand what actions are available without prior external documentation.

Signup and view all the flashcards

WS-Security in SOAP Web Services

WS-Security is a standard used to secure SOAP-based web services, providing authentication, message integrity (ensuring message hasn't been tampered with), and confidentiality (encrypting message content). It's crucial for sensitive data exchange in web services.

Signup and view all the flashcards

Strategy Pattern: Why Composition?

The Strategy pattern in Java allows you to dynamically switch between different algorithms or implementations at runtime. It uses composition over inheritance to achieve flexibility, as you can plug in different algorithm objects to your main object.

Signup and view all the flashcards

The Bridge Pattern

The Bridge pattern in Java decouples an abstraction (interface or abstract class) from its implementation (concrete classes), allowing both to vary independently. Think of it as separating different aspects of a system, allowing for more manageable and flexible code.

Signup and view all the flashcards

Protection Proxy Pattern

The Protection Proxy pattern in Java provides access control to an object by filtering operations. Some actions are allowed, others are blocked, effectively controlling who can access the real subject object.

Signup and view all the flashcards

State Pattern

The State pattern in Java allows an object to change its behavior based on its internal state. The object's functionality can vary depending on the current state, allowing for more dynamic and context-aware behavior.

Signup and view all the flashcards

Singleton Pattern in Multithreaded Environments

The Singleton pattern in Java ensures that a class has only one instance. However, in a multithreaded environment without proper synchronization, multiple threads can concurrently attempt to create an instance, potentially leading to multiple singleton instances, violating the pattern's core principle.

Signup and view all the flashcards

Microservices Architecture: Key Principle

Microservices architecture is built around the idea of creating small, independent, self-contained services that communicate with each other. This approach emphasizes loose coupling, making services flexible and scalable.

Signup and view all the flashcards

Service Registry in Microservices

A service registry acts as a central directory in a microservices architecture. It allows services to discover and locate each other dynamically. This eliminates hard-coded dependencies and enables services to adapt to changes in the system.

Signup and view all the flashcards

The Role of API Gateway in Microservices

An API gateway in a microservices architecture is a central entry point for client requests. It routes requests to the appropriate microservice based on their path, headers, or other criteria. It simplifies client interactions and provides a consistent interface.

Signup and view all the flashcards

CAP Theorem in Distributed Systems

The CAP theorem states that a distributed system cannot simultaneously ensure Consistency (data is always synchronized), Availability (system is always operational), and Partition Tolerance (system works even if parts are isolated). You have to choose two out of three, depending on your system's requirements.

Signup and view all the flashcards

Circuit Breaker Pattern in Microservices

The Circuit Breaker pattern helps improve resilience in microservices. It prevents cascading failures by temporarily stopping calls to a service that is failing. If the service returns to a healthy state, the circuit breaker will allow calls again.

Signup and view all the flashcards

JavaScript this Keyword in Callbacks

In JavaScript, the this keyword's value depends on how the function is called. In this case, the function sum is called without an object context, so this refers to the global object in the browser, which is a window object. Since window object doesn't have a and b properties, the calculation results in NaN.

Signup and view all the flashcards

CSS3 Transform Property for 3D Effects

The transform property in CSS3 allows you to apply 3D transformations to elements. These transformations can include rotations, translations, scaling, and skewing, creating visually interesting effects.

Signup and view all the flashcards

Grouping Options in a Dropdown List

The <optgroup> element in HTML5 is used to group a set of options within a select element (dropdown list). This allows you to logically group related options for better organization and user experience.

Signup and view all the flashcards

CSS position: sticky; Property

The position: sticky; property in CSS3 makes an element stick to the viewport when the user scrolls. Initially, the element remains in its normal position. But once the scroll position passes a certain threshold, the element will stick to the viewport, ensuring it remains visible.

Signup and view all the flashcards

JavaScript this in IIFEs

In this JavaScript code, the IIFE (Immediately Invoked Function Expression) creates a new scope. Inside the IIFE, this refers to the global object (window object in browser environment). So, typeof this returns "object".

Signup and view all the flashcards

React's useEffect Hook

The useEffect hook in React is used to perform side effects like fetching data, setting up subscriptions, or interacting with the DOM. The dependency array ([]) ensures that the side effect runs only once on initial render.

Signup and view all the flashcards

React's useMemo Hook

The useMemo hook in React memoizes the return value from a function. This means that if the function's dependencies haven't changed, the cached result is returned. This helps optimize performance by preventing unnecessary recalculations.

Signup and view all the flashcards

React's React.memo Function

The React.memo function in React is used to memoize functional components. It checks if the component's props have changed and only renders the component if something has changed. This helps avoid unnecessary re-renders and improves performance.

Signup and view all the flashcards

React's useCallback Hook

The useCallback hook in React memoizes a callback function. This means that the callback function only re-creates when its dependencies change. This is helpful to prevent unnecessary re-renders of child components that rely on this callback.

Signup and view all the flashcards

React Context API

The React Context API provides a way to share data and state across components without manual prop drilling. This is helpful for passing data like themes, user preferences, and other global data.

Signup and view all the flashcards

AWS Service for Running Docker Containers

Amazon ECS (Elastic Container Service) is a fully managed container orchestration service for deploying, scaling, and managing containerized applications. It integrates seamlessly with Docker and provides features like service discovery and load balancing.

Signup and view all the flashcards

AWS Lambda: Serverless Computing

AWS Lambda is a serverless compute service that lets you run code without managing servers. You can upload your code and Lambda will automatically execute it when triggered by events such as HTTP requests, database changes, or file uploads.

Signup and view all the flashcards

AWS CloudFormation: Infrastructure as Code

AWS CloudFormation lets you model and provision your AWS resources using templates. It automates the creation, updating, and deletion of resources, making it easier to manage your infrastructure as code.

Signup and view all the flashcards

AWS DynamoDB: NoSQL Database

Amazon DynamoDB is a fully managed NoSQL database service that provides high performance and scalability. It uses a key-value store model and is suitable for applications that require fast data access.

Signup and view all the flashcards

AWS CodePipeline: CI/CD Service

AWS CodePipeline is a fully managed continuous integration and continuous delivery (CI/CD) service that lets you automate the build, test, and deployment of your applications. It integrates with other AWS services like CodeCommit, CodeBuild, and CodeDeploy.

Signup and view all the flashcards

SQL HAVING Clause

The HAVING clause in SQL is used to filter groups of rows after they have been aggregated using the GROUP BY clause. It allows you to apply conditions to the aggregated results.

Signup and view all the flashcards

Correlated Subquery in SQL

A correlated subquery in SQL is a subquery that refers to a column (or columns) from the outer query. It is evaluated for each row returned by the outer query, allowing you to conditionally filter or retrieve data based on the values in the outer query.

Signup and view all the flashcards

Creating an Index in SQL

To create an index on a table in SQL, you use the CREATE INDEX statement. Indexes help speed up data retrieval by creating a sorted structure that contains a subset of the table's data, making searching more efficient.

Signup and view all the flashcards

Study Notes

CORE JAVA

  • String Comparison:

    • Comparing string literals (s1 and s2) results in true.
    • Comparing a literal with a newly created string (s1 and s3) returns true for equality but false for object reference equality.
  • Loop Output:

    • The code iterates through numbers from 1-9.
    • It skips multiples of 2.
    • It breaks when y equals 8.
    • The output is 1357.
  • Class Hierarchy Output:

    • In a class hierarchy, properties are inherited, but overridden members take precedence.
    • The output of obj.a is 10 when obj refers to an A object.
    • Because of inheritance, the obj variable is actually a reference to class B object even though the variable name is obj. The output from A is printed

J2EE

  • J2EE Components:

    • Servlets, JSPs, and Enterprise JavaBeans (EJBs) are components of J2EE architecture.
    • AWT (Abstract Window Toolkit) is not part of J2EE.
  • EJB Functionality:

    • EJBs support distributed transactions.
    • They are used for enterprise-level functionality.
  • JNDI Role:

    • JNDI (Java Naming and Directory Interface) provides an API for directory service lookup and data retrieval based on names.
  • Deployment Descriptor:

    • The web.xml deployment descriptor configures web application deployment, defining servlets and URL mappings.

Hibernate

  • Immutability Mapping:

    • Use the @Immutable annotation to map immutable entities in Hibernate.
  • Fetch Mode:

    • @Fetch(FetchMode.SUBSELECT) fetches associated collections using a subselect query in one database roundtrip to boost efficiency.
  • Second-Level Cache:

    • The second-level cache in Hibernate is visible to all sessions and is not specific to a single session.
  • Optimistic Locking:

    • The @version annotation is used for optimistic locking in Hibernate. It marks the field for version checking to prevent conflicts if multiple developers try to edit the same database records

Spring

  • Component Scanning:

    • The @Component annotation is used to define a Spring component, enabling automatic detection and registration by Spring.
  • Dependency Injection:

    • @Autowired automatically injects dependencies by type.
  • Spring Boot:

    • Spring Boot uses a CLI for development, testing, and packaging, reducing boilerplate code.
  • Transactions:

    • @Transactional marks a method for transaction management.
  • Custom Scopes:

    • Use the @Scope annotation for customized bean scopes.

Web Services

  • WSDL (Web Services Description Language):

    • WSDL describes web service methods, including parameters and return types. This description is used in service discovery and communication.
  • HTTP Methods (REST):

    • PUT is an idempotent HTTP method usually used for resource updates in RESTful web services.
  • UDDI:

    • UDDI (Universal Description, Discovery, and Integration) acts as a registry for businesses and their web services, enabling clients to discover web services based on names.
  • HATEOAS:

    • HATEOAS (Hypermedia As The Engine Of Application State) is a critical concept in RESTful web services, where the next steps are hyperlinked in returned documents. The client learns which actions are possible and how to make those actions by examining the links.
  • WS-Security:

    • WS-Security is not used to encrypt data at rest.

Java Web Design

  • JavaScript Output:

    • Javascript code outputing NaN as the result of summing a function.
  • 3D Transformation: -The transform property is used in CSS3 to apply various 3D transformations to an element.

  • HTML5 Options Grouping: -The optgroup element in HTML5 is used to group options together in a drop-down list for better organization

  • Sticky Positioning: -The position: sticky attribute in CSS3 positions an element relative to its normal position but makes it fixed at a specific offset to the viewport as the user scrolls.

React

  • Component Re-rendering:

    • React.memo prevents re-rendering of a component if its props haven't changed.
  • Use Callback:

    • The output from the snippet is 2 because of the React.useCallback hook, which memoises the callback.
  • Context API:

    • Context API in React can be used to pass values without prop drilling if the desired props are needed deeper down in the component tree

AWS

  • Docker Containers:

    • Amazon ECS (Elastic Container Service) is used for running Docker containers in AWS.
  • AWS Lambda:

    • Lambda runs code without provisioning or managing servers, typically used for serverless functions.
  • CloudFormation:

    • AWS CloudFormation automates resource management; provisioning, and configuration changes by treating resources as code.
  • DynamoDB:

    • Amazon DynamoDB is a NoSQL database service in the cloud.
  • CI/CD:

    • AWS CodePipeline is a CI/CD service to automate changes (integration, testing, and deployment) to software.

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Related Documents

Java MCQ PDF

Description

Test your knowledge on Core Java string comparisons, loop outputs, and class hierarchy, along with J2EE components like Servlets and EJBs. This quiz will challenge your understanding of object-oriented programming and enterprise architecture in Java.

More Like This

Core Java Quiz
5 questions

Core Java Quiz

AttentiveMossAgate avatar
AttentiveMossAgate
Core Java Syntax and Features Quiz
5 questions
Core JAVA Unit 1
10 questions

Core JAVA Unit 1

CheerfulExuberance7373 avatar
CheerfulExuberance7373
Use Quizgecko on...
Browser
Browser