Welcome to LearnWithRehan! My channel is dedicated to helping students and learners of all ages improve their study habits, grasp difficult concepts, and stay motivated. From subject-specific tutorials to tips for better learning, I’m here to make education fun and accessible. Whether you’re preparing for exams or just looking to expand your knowledge, you’ll find valuable insights here. Subscribe and start your learning journey with me!
LearnWithRehan
🔄 SQL में Column Name कैसे बदलें? (Best Explanation)
SQL Server में किसी भी टेबल के column name को rename करने के लिए हम sp_rename command का इस्तेमाल करते हैं।
अगर आपकी टेबल का नाम fcm_tokens है और आप पुराने column visitor_id को बदलकर user_id रखना चाहते हैं, तो SQL में ये query लिखें:
EXEC sp_rename 'fcm_tokens.visitor_id', 'user_id', 'COLUMN';
✔ यह Query क्या करती है?
fcm_tokens → आपकी table का नाम
visitor_id → पुराना column name
user_id → नया column name
COLUMN → SQL Server को बताता है कि आप एक column को rename कर रहे हैं
📌 Important Note:
Column rename करने से data delete नहीं होता, सिर्फ नाम बदलता है। इसलिए यह command safe है।
3 weeks ago | [YT] | 0
View 0 replies
LearnWithRehan
What does the method calculateTotal() return?
4 weeks ago | [YT] | 0
View 0 replies
LearnWithRehan
What will happen if product.isAvailable(quantity) returns false in the Order class?
4 weeks ago | [YT] | 0
View 0 replies
LearnWithRehan
Which method is responsible for reducing the number of items in stock?
4 weeks ago | [YT] | 0
View 0 replies
LearnWithRehan
What does the method isAvailable(int quantity) most likely return?
4 weeks ago | [YT] | 0
View 0 replies
LearnWithRehan
Which OOP concept is used when a Product class contains attributes like name, price, and stock?
4 weeks ago | [YT] | 0
View 0 replies
LearnWithRehan
Full Code
📌 Java Code Example – Online Shopping Order Processing:-
// Real-life example: Online Shopping Order
class Product {
String name;
double price;
int stock;
Product(String name, double price, int stock) {
this.name = name;
this.price = price;
this.stock = stock;
}
boolean isAvailable(int quantity) {
return stock >= quantity;
}
void reduceStock(int quantity) {
stock -= quantity;
}
}
class Order {
Product product;
int quantity;
Order(Product product, int quantity) {
this.product = product;
this.quantity = quantity;
}
double calculateTotal() {
return product.price * quantity;
}
void placeOrder() {
if (product.isAvailable(quantity)) {
product.reduceStock(quantity);
System.out.println("Order placed successfully!");
System.out.println("Product: " + product.name);
System.out.println("Quantity: " + quantity);
System.out.println("Total Amount: ₹" + calculateTotal());
} else {
System.out.println("Sorry! Not enough stock for " + product.name);
}
}
}
public class EcommerceApp {
public static void main(String[] args) {
Product laptop = new Product("Dell Laptop", 55000, 5);
// User places an order for 2 laptops
Order order1 = new Order(laptop, 2);
order1.placeOrder();
// Another user places an order for 4 laptops (not enough stock!)
Order order2 = new Order(laptop, 4);
order2.placeOrder();
}
}
4 weeks ago | [YT] | 0
View 0 replies
LearnWithRehan
Can Generics be used with enums?
1 month ago | [YT] | 0
View 0 replies
LearnWithRehan
Can we have static members in a generic class?
1 month ago | [YT] | 0
View 0 replies
LearnWithRehan
Can we use multiple bounds in Generics
1 month ago | [YT] | 0
View 0 replies
Load more