Tuesday, February 27, 2024

Java Constructor

what is constructor?


A constructor is special method used to initialize objects.
  • The constructor is called when an object of a class created.
  • constructor is name must match the class name.
  • it cannot have a return type(like void).
  • constructors can not inherited by subclass, but the constructor of the superclass can be invoked from the subclass. 
  • All classes have constructors by default: if you do not create a class constructor yourself, Java creates one for you. 
  • Constructors are called only once at the time of Object creation while method(s) can be called any number of times. 
  • Constructor in Java can not be abstract, final, static, or Synchronized.

Types of constructors in Java 
Default constructor 
Parameterised Constructor 
Copy constructor


 ➤Default constructor 

  • A constructor that has no parameters is known as default the constructor. 
  • if we create a default constructor with no arguments, the compiler does not create a default constructor


➤Parameterised constructor 

  • A constructor that has parameters is known as parameterized constructor. 

 1) Example of parameterised constructor 
 public class A
 {
 int x; 
 public A(int y)
 {
 x = y;
 }
 public static void main(String[] args) 
A obj = new A(5);
 System.out.println(obj.x);
 }
 } 

 2)Example of parameterised constructor (using "this" keyword)
 public class A 
 int x; 
 public A(int x) 
{ this.x=x; 
 }
 //constructor 
 public static void main(String[] args) 
{
 A obj = new A(5);
 System.out.println(obj.x);
 }
 }

 ➤Copy constructor 

  •  Like C++, Java also supports a copy constructor. But, unlike C++, Java doesn’t create a default copy constructor if you don’t write your own.

NOTE : 

  •  If constructors are inherited (class is inheriting other classes) then always first parent class's constructors invoke first one by one then child classes. 
  • Java does not call a parameterized constructor implicitly, you need to explicitly invoke parameterised constructor.
  • In Java, when you create an object of a child class, the default constructor of the parent class is implicitly called. If the parent class has a parameterized constructor and no default constructor is explicitly defined, you need to ensure that the child class constructor explicitly calls the appropriate parent constructor using the super keyword

Factorial in java

import java.util.*;

public class fact

{

public static void main (String [] args) {

System.out.println("Enter the no:" ) ;

Scanner s=new Scanner(System.in);

int a=s.nextInt();

int fact =1;

for(int i=0; i<=a; i++) 

fact = fact*i;

}

System.out.println("factorial of" +a+ "number is"  +fact) ;

}



output - Enter the no.

5

factorial of 5 number is 120

What is software testing??

 



Software testing is a process of identifying the correctness of software by considering its all attributes (Reliability, Scalability, Portability, Re-usability, Usability) and evaluating the execution of software components to find the software bugs or errors or defects.



-------Types of testing-------((

:( Manual testing

In manual testing there are some types 

White box testing

Black box testing

Gray box testing

Sunday, February 4, 2024

Differentiate between the top down and the bottom up approach in designing software

 

S.No.

Top-Down Approach

Bottom-Up Approach

1.

In this approach, the problem is broken down into smaller parts.

In this approach, the smaller problems are solved.

2.

It is generally used by structured programming languages such as C, COBOL, FORTRAN, etc.

It is generally used with object oriented programming paradigm such as C++, Java, Python, etc.

3.

It is generally used with documentation of module and debugging code.

It is generally used in testing modules.

4.

It does not require communication between modules.

It requires relatively more communication between modules.

5.

It contains redundant information.

It does not contain redundant information.

6.

Decomposition approach is used here.

Composition approach is used here.

7.

The implementation depends on the programming language and platform.

Data encapsulation and data hiding is implemented in this approach.

Saturday, February 3, 2024

what is prototype

 A prototype is an early sample, model or release of a product built to test a concept of process. It can be used in for variety of context, including semantics design electronics and software programming.

A Prototype can serve as a model or inspiration for those that come later. It can also mean an original model on which something is patterned, a standard or typical example, or a full-scale and usually functional form of a new type or design of a Constuction.

For example, a software developer might create a prototype of a new application to test its functionality and user interface before building the final version. Similarly, a car manufacturer might create a prototype of a new vehicle to test its design and performance before beginning mass production.;


waterfall models

 

waterfall model phases


The main drawback of the waterfall model is the difficulty of accommodating change after the process is underway. One phase has to be complete before moving onto the next  phase. 
 
 problems

Inflexible partitioning of the project into distinct stages makes it difficult to respond to changing customer requirements.

Therefore, this model is only appropriate when the requirements are well-understood and changes will be fairly limited during the design process.
The waterfall model is mostly used for large systems engineering projects where a system is developed at several sites.

Question and answer of Software Engineering

Q.1-   Explain various component of Software.

Ans-  

  1. System Software:

    • Operating System (OS): The fundamental program that manages computer resources (memory, CPU, storage, etc.) and provides an interface for users to interact with the system. Exampels include linux, macOS and windows.
    • Language processor: converts high-level programming languages(like Java, C++, python) into machine-readable instructions (object code or machine code).
    • Device Driver : Controls externals devices(printers, mice, modems) and enables them to function with the computer system.
  2. Application Software:

    • General Purpose Software; Versatile programs used for various task(eg- web browsers, office suites, media players).
    • Customized Software: Tailored solutions for specific business needs or industries.
    • Utiltiy Software: Tools that enhance system performance, security, or maintanance (eg: antivirus, disk cleanup).
  3. Software Components
  • Modules: Specific functions or sets of functions (e.g., a calculator module).
  • Software Components: Well-defined, modular, reusable functionalities that interact with other components. they integrate specific functions or groups of function.
  • Individual Software Components: These encapsulate related functions or data and communicate with each other via interfaces. Each component provide a 'Provide interface' for other components to use.

Software Engineering notes for BCA students

 Introduction- 

what is Software

  • Computer programs and associated documentation such as requirements, design models and user manuals.
  • Software products may be developed for a particular customer or may be developed for a general market.
  • Software products may be - {
  • Generic- developed to be sold to a range of diffrent customers.
  • Custom - developed for a single customer according to their specification.  
        }
  • New Software can be created by developing new programs, configuration  generic software systems or reusing existing software.

What is Software engineering?

software engineering is an engineering discipline that is concerned with all aspects of software production.
Software engineers shuold adopt a systematic and organized approach to their work and use appropriate tools and techniques depending on the problem to be solved, the development contraints and the resources available.


What is the difference between softwae engineering and computer science?

Computer science is concerned with theory and fundamentals; software engineering is concerned with the practicalities of developing 

✅ UNIT 4 — POSET, LATTICES & BOOLEAN ALGEBRA (DISCRETE MATHEMATICS)

  ✅ UNIT 4 — POSET, LATTICES & BOOLEAN ALGEBRA 1. Poset Partially Ordered Set A pair (A, ≤) where relation is: Reflexive Anti-...