418
订阅者
无数据24 小时
-27 天
+1230 天
帖子存档
What happens when a method returns an object in a class annotated with @RestController?
Which annotation is specifically designed for building RESTful APIs?
Which annotation is used for handling web requests and returning views?
Q. Difference between @Controller and @RestController annotation ?
@Controller and @RestController are both annotations in Spring Boot, but they serve slightly different purposes:
**@Controller:**
==============================
- Indicates a class is a web request handler (e.g., a servlet).
- Typically used for handling web requests and returning views (e.g., HTML pages).
- Methods can return various types, including strings, views, and objects.
- Does not automatically convert return values to JSON or other formats.
**@RestController:**
==============================
- A specialized version of @Controller for building RESTful web services.
- Automatically converts return values to JSON or other formats (using HTTP message converters).
- Methods can return objects, which are automatically serialized to JSON or other formats.
- Implicitly assumes the handling of HTTP requests and respIn summary:mmary:**
- **@Controller** is for handling web requests and returning views or other types of responses.
- **@RestController** is specifically designed for building RESTful APIs and automatically converts return values to JSON or other formats.
- When building a RESTful API, use @RestController to simplify the process and leverage automatic conversion features.
- For handling web requests and returning views, use @Controller.Full stack web development
https://drive.google.com/drive/folders/1n_bVmiHFZVGBKP-6bI3hvuqytxoykh_Q
𝗖𝗼𝘃𝗲𝗿 𝗧𝗼𝗽𝗶𝗰𝘀 𝗶𝗻 𝘁𝗵𝗶𝘀 𝗗𝗿𝗶𝘃𝗲 ⬇️
⏺ HTML
⏺ CSS
⏺ javascript
⏺ Bootstrap
⏺ JQuery
⏺ ReactJs
⏺ API (RESTFul api)
Must open this drive and start learning
(Jada idhar udhar mat bhagiye ikk chiz ko pakad kr usko complete kriye
Phele)
https://youtube.com/@codingdrawrun?si=PHs6nEU-AfOM6aIv
👨💻 Java Coding Challenge
A. true
B. false
C. null
⬇️ Guess the code output in the comments!
🧑💻 Java Quiz
What is the purpose of the toString() method in Java?
A. To convert an object to a primitive data type.
B. To compare two objects for equality.
C. To return a string representation of an object.
D. To throw an exception if an object is null.
⬇️ Guess the correct option in the comments!
==============================
𝐈𝐍𝐓𝐄𝐑𝐕𝐈𝐄𝐖 𝐐𝐔𝐄𝐒𝐓𝐈𝐎𝐍
==============================
Q. What is difference between Break and Continue in Java ?
"Break" and "Continue" are both keywords in Java, used in loops and conditional statements.
"Break" is used to:
- Exit a loop or switch statement immediately
- Stop executing the current block of code
- Transfer control to the next statement after the loop or switch
"Continue" is used to:
- Skip the current iteration of a loop
- Move to the next iteration of the loop
- Only execute the next statement if the condition is true
In other words:
- "Break" says "Stop here and get out!"
- "Continue" says "Skip this iteration and move to the next one!"
≠=============================
LEARN 2MIN ONLY
==============================
👨💻 Java Quiz
Which collection class in Java does not allow duplicates?
A. ArrayList
B. HashSet
C. LinkedList
⬇️ Guess the correct option in the comments!
👨💻 Java Coding Challenge
A. NPE
B. 0
C. no output
⬇️ Guess the code output in the comments!
𝗤. 𝗪𝗵𝗮𝘁 𝗮𝗿𝗲 𝘁𝗵𝗲 𝗠𝗲𝗺𝗼𝗿𝘆 𝗔𝗹𝗹𝗼𝗰𝗮𝘁𝗶𝗼𝗻𝘀 𝗮𝘃𝗮𝗶𝗹𝗮𝗯𝗹𝗲 𝗶𝗻 𝗝𝗮𝘃𝗮𝗝𝗮𝘃𝗮?
Java has five significant types of memory allocations.
· Class Memory
· Heap Memory
· Stack Memory
· Program Counter-Memory
· Native Method Stack Memory
𝟭. 𝗖𝗹𝗮𝘀𝘀 𝗠𝗲𝗺𝗼𝗿𝘆
𝐖𝐡𝐚𝐭: Stores class-related data like methods and static variables.
𝐖𝐡𝐞𝐫𝐞: In Metaspace (Java 8+) or PermGen (pre-Java 8).
𝟮. 𝗛𝗲𝗮𝗽 𝗠𝗲𝗺𝗼𝗿𝘆
𝐖𝐡𝐚𝐭: Stores objects and instance variables.
𝐖𝐡𝐞𝐫𝐞: In the heap, divided into Young Generation and Old Generation.
𝟯. 𝗦𝘁𝗮𝗰𝗸 𝗠𝗲𝗺𝗼𝗿𝘆
𝐖𝐡𝐚𝐭: Stores local variables and method call information.
𝐖𝐡𝐞𝐫𝐞: Each thread has its own stack.
𝟰. 𝗣𝗿𝗼𝗴𝗿𝗮𝗺 𝗖𝗼𝘂𝗻𝘁𝗲𝗿 (𝗣𝗖) 𝗥𝗲𝗴𝗶𝘀𝘁𝗲𝗿
𝐖𝐡𝐚𝐭: Holds the address of the current JVM instruction.
𝐖𝐡𝐞𝐫𝐞: Each thread has its own PC register.
𝟱. 𝗡𝗮𝘁𝗶𝘃𝗲 𝗠𝗲𝘁𝗵𝗼𝗱 𝗦𝘁𝗮𝗰𝗸
𝐖𝐡𝐚𝐭: Used for executing native methods via JNI (Java Native Interface).
𝐖𝐡𝐞𝐫𝐞: Each thread has its own native method stack.
👨💻 Java Quiz
Which method is used to start a thread execution in Java?
A. run()
B. start()
C. execute()
⬇️ Guess the correct option in the comments!
👨💻 SQL Quiz
Which SQL function is used to return the largest value from a set of values?
A. MAX()
B. BIGGEST()
C. HIGHEST()
⬇️ Guess the correct option in the comments!
𝐐. 𝐖𝐡𝐚𝐭 𝐢𝐬 𝐒𝐢𝐧𝐠𝐥𝐞𝐭𝐨𝐧 𝐜𝐥𝐚𝐬𝐬 𝐢𝐧 𝐉𝐚𝐯𝐚?
A Singleton class in Java is a class that allows only one instance/Object of itself to be created and provides a way to access that instance/Object globally.
(i.e only one time object created)
𝐲𝐨𝐮 𝐜𝐚𝐧 𝐜𝐫𝐞𝐚𝐭𝐞 𝐚 𝐒𝐢𝐧𝐠𝐥𝐞𝐭𝐨𝐧 𝐜𝐥𝐚𝐬𝐬 𝐛𝐲 𝐟𝐨𝐥𝐥𝐨𝐰𝐢𝐧𝐠 𝐭𝐡𝐞𝐬𝐞 𝐬𝐭𝐞𝐩𝐬:
⏺ Make the 𝐜𝐨𝐧𝐬𝐭𝐫𝐮𝐜𝐭𝐨𝐫 of the class private to prevent outside instantiation.
⏺ Create a private static instance/Object of the class within the class itself.
⏺ Provide a public static method that returns the instance of the class. If the instance is null, create a new instance; otherwise, return the existing one.
What is the difference between Java collection and Java collections?
𝗝𝗮𝘃𝗮 𝗖𝗼𝗹𝗹𝗲𝗰𝘁𝗶𝗼𝗻
==============================
𝗗𝗲𝗳𝗶𝗻𝗶𝘁𝗶𝗼𝗻: Collection is an interface.
𝗜𝗻𝘁𝗿𝗼𝗱𝘂𝗰𝘁𝗶𝗼𝗻: Introduced in Java 1.2.
𝗣𝘂𝗿𝗽𝗼𝘀𝗲: Provides the framework for representing and manipulating groups of objects (like List, Set, Queue).
Advantage (Collection): Standardizes the way groups of objects are handled.
Java Collections
Definition: Collections is a utility class.
Introduction: Introduced in Java 1.2.
Purpose: Provides static methods for sorting, searching, and modifying collections.
Advantage (Collections): Offers utility methods to simplify common tasks on collections.
