Posts

Showing posts with the label oop

Flexible Constructor Bodies: A Preview Feature in Java 24 (JEP 492)

     With the introduction of JEP 492, Java brings a new way to handle constructors, making them more flexible and intuitive. This enhancement allows developers to include statements before an explicit constructor invocation ( super() or this() ) — something that was previously forbidden. Let’s explore how this improves constructor behaviour, making code simpler and more maintainable. Old Behaviour In Java, constructors followed a rigid rule: the first statement in a constructor must be an explicit constructor invocation ( super() or this() ). If omitted, the compiler automatically added super() . This ensured that superclass constructors executed first, guaranteeing safe object initialisation. take an example where we want to validate arguments - Example: Argument Validation in Old Java public class PositiveBigInteger extends BigInteger { public PositiveBigInteger(long value) { super(value); // Must call super firs...

Library Management system implementation in CPP(C++)

      Library management system implementation could be a great assignment/project to polish many different concepts in C++. Here we have implemented the library management using structures like linked lists but in a two-dimensional manner. This does not use any database, but the concepts can be extended to a database instead. This implementation is perfect for college/university assignments, and personal project purposes.      This program in C++ uses many different concepts of Programming such as - Object-oriented programming, Linked list, Pointers, Complex data structures etc.      The problem statement for this Program may be -  " In a library, for each book book-id, serial number (denotes copy number of a book), title, author, publisher and price are stored. Book-id and serial number together will be a unique identifier for a book. Members are either students or faculty. Each member has a unique member-id. Name, e-mail and address a...