Posts

Showing posts from 2022

Datatypes in java

Data Types In Java There are two data types available in Java: 1.Primitive Data Types 2.Reference/Object Data Types  (Non Primitive) Primitive Data Types: There are eight primitive data types supported by Java. Primitive data types are predefined by the language and named by a keyword. The eight primitive data types are explained below: byte: Byte data type is an 8-bit signed two's complement integer. Minimum value is -128 (-2^7) Maximum value is 127 (inclusive)(2^7 -1) Default value is 0 Byte data type is used to save space in large arrays, mainly in place of integers, since a byte is four times smaller than an int. Example: byte a = 100 , byte b = -50 short: Short data type is a 16-bit signed integer.  Minimum value is -32,768 (-2^15) Maximum value is 32,767 (inclusive) (2^15 -1) Short data type can also be used to save memory as byte data type. A short is 2 times smaller than an int Default value is 0. Example: short s = 10000, short r = -20000 int : Int data type is a 32-bit si

Type casting in cpp

  Type casting.{short} Reference variable: - Reference variable produces an aliens ( alternative name) feel a precously defined variable. Syntax:- data type &reference_variable_nm=variable_nm ; Ex:-int sum=100; int &total=sum; ⇒ handsome is the inter type variable that has already been declared and total is the alternative name declared to the present variable sum. cout<<sum; cout<<total; ⇒ Both statement prints the value 100 Sum=sum+20; Will change the value of both total and sum. ⇒A reference variable must be initialised at the time of declaration. ⇒Hence, both the variable sum and the total reference to the same letter object in the memory. ⇒Hence, "&" percent is not an address operator. Program on reference variable. #include<iostream.h> int main() { int sum=200; int & total=sum; cout<<"sum="<<sum<<"\ntotal="<<total; sum=sum+30; cout<<"\nsum="<<sum<<"\ntotal

Scope resolution in cpp

  Scope Resolution Operator This operator is used to access the Global variable but also has a local variable with a same variable name. Syntax:- ::Variable_name;  Return type<class_name>::method_name() { State_1; State_2; : : } ↣It used to define number of functions outside of the class.                           Ex:- #include<iostream.h> int a=30; int main() { int a=20; cout<<"::a="<<::a<<"\n"; cout<<"a="<<a; return 0; } Out put:- ::a=30 a=20

Java virtual machine(JVM)

  JVM (JAVA VIRTUAL MACHINE) A Java virtual machine (JVM), an implementation of the Java Virtual Machine Specification, interprets compiled Java binary code (called bytecode) for a computer's processor (or "hardware platform"). S that it can perform a Java program's instructions. Java was designed to allow application programs to be built that could be run on any platform without having to be rewritten or recompiled by the programmer for each separate platform. A Java virtual machine makes this possible because it is aware of the specific instruction lengths and other particularities of the platform. JVM generates machine code for its corresponding machine from the byte code.

String handling functions

  Strings String Class  String is a class in java that is final String in Java programming, are a sequence of characters. In the Java programming language, strings are objects. String is also a data type in java  All string literals in Java programs, such as "abc", are implemented as instances of this class. Strings are constant; their values cannot be changed after they are created Example of String String a="Hello"; String b=new String(); String c=new String("Hello");   Methods in String Class   Basic Methods 1. s.concat(String s2) Concatenates one string onto another. Appends the String s2 to the String s. Example: String str1 = new String("Hello "); String str2 = new String("World"); String str3 = str1.concat(str2); System.out.println(str3); The output  is "Hello World":   2. s.length()   Returns the length of the string. Example: String str1 = new String("Hello "); int n=str1.length(); System.out.println("L

Looping statements

while () Statement:          This executes a block of statements as long as a specified condition is true. Syntax : while(condition) { statement(s); } next_statement; The (condition) may be any valid Java expression. The statement(s) may be either a single or a compound (a block) statement. Execution : When program execution reaches a while statement, the following events occur: The (condition) is evaluated. If (condition) evaluates as false the while statement terminates and execution passes to the first statement following statement(s) that is the next_statement. If (condition) evaluates as true the  statement(s) iside the loop are executed. Then, the execution returns to step number 1. Example : int i=0;  //Initialize loop variable System.out.println("Even numbers\n"); while(i<=10) { System.out.println(i); i+=2; } do..while()  Statement do..while loop is used when you need to run some statements and processes once at least before checking the condition to execute the l

Constructors in java

Constructors A constructor can be thought of as a specialized method of a class that creates (instantiates) an instance of the class and performs any initialization tasks needed for that instantiation. The sytnax for a constructor is similar but not identical to a normal method. It follows the rules mentioned below The name of the constructor must be exactly the same as the class it is in. Constructors may be private, protected or public. A constructor cannot have a return type (even void). This is what distinguishes a constructor from a method. Multiple constructors may exist, but they must have different signatures, i.e. different numbers and/or types of input parameters. Default constructor: If you don't define a constructor for a class, a default parameter less constructor is automatically created by the compiler. The default constructor calls the default parent constructor (super()) and initializes all instance variables to default value (zero for numeric types, null for objec

Control statements

Conditional control statements in java Conditional control or decision making is done in java with if statements and switch statement. Simple if() Ensures that a statement is executed only when a condition is true.  Conditions typically involve comparison of variables or quantities for equality or inequality Syntax :  if(condition)   {       statement;   }   statement;   Example :  if (age >= 18) System. out.println(“You are eligible to vote.”); if ... else() This is two way branching statement  and is an extension of if statement and informs what to do if the condition evaluates to false. Syntax :  if(condition)   {       statement;   }   else   {                              statement;   }   Example : if(a>b) System.out.println("A is big"); else System.out.println("B is big"); Nested if() When if ..else statement is placed inside another if..else statement then it is called nested if…else statement. This is used for making multiway decisions Syntax :   

Types of constructors

Image
Type of Constructors. ⇒In C++  a constructor is an special Member function which automatically gets called . Whenever, the object of a class is initialised. ⇒The constructor is defined by defining the Member function or method name and class name are same or similar. ↦There are four types of constructors . They are A】 Default Constructor ⇒Constructor are accessed automatically, when the object is initialised or created. ⇒ one's object is created constructors are invoked automatically. Syntax:- Class_name <object_name>; Ex:-A.obj; Sample program #include<iostream.h> class x { public: x() { cout<<"Hi shashi"; }}; int main() { x a; return 0; } B】 Parameterized Constructor ⇒In C++, Parametrized Constructor is as like as default constructor .But, the constructor which has the arruguments is known as the Parameterized Constructor. Sample program #include<iostream.h> class area { public: area(double r) { cout<<"area of circle="<<(r*r

Pass by value, pass by reference, call by referance

  Pass by valu, pass by reference , call by reference a】Call by value ⇒ In Call by Value the value that is fast is not changed after foming some operations on it. ⇒ In Call by Value it creates at caps of the variable into stack memory or stack section ⇒ when the value is changes the change value create a copy with actual value remaining the change Ex:- #include<iostream.h> #include<conio.h> class abc { public: void add(int a,int b) { int c; c=a+b; cout<<"c="<<c; } }; int main() { abc s; clrscr(); s.add(4,5); getch(); } b】 pass by reference ⇒In Call by Reference function we pass the arguments with reference variable by using emperent ⇒In Call by Reference, actual value is passed as the argument ,it argument is changed after forming some options on it ⇒When Call by Reference it use it create the Call by Reference a copy of reference into the copy of the reference into the Stark section of memory. ⇒In Call by Reference if the value is modified than the ac

Operators with programm

  Operators with Program . →All 'C'-Operature are valid in C++ also in addition c++ introduce some new operators they are Operator Symbol  Operator Name << Insertion  >> Extraction ::  Scope resolution ::* Pointer to member declaration →* Pointer to member operator memory allocation operator new Memory allocation operator delete  memory deallocation operator endl line feed operator new line setw field width operator i 】Insertion operator(<<) & Extraction operator(>>) :- This two operators are used to insert and display the values as like as printf () and scanf(). Syntax:- Extraction operator:- cin>>variable-name; Insertion cout<<variable_name ; Program on Insertion & Extrration operatore. #include<iostream.h> int main() { int a; cout<<"Enter a value\n";//Insertion operator cin>>a; //Extraction operator cout<<"a="<<a; return 0; } Out put:- Enter a value 8 a=8 ii】 Scope Resolution Opera

Difference between C & C++

  Differences between C and C++.   C C++ 1】C support procedural oriented programming paradigm for code development. 1】C++ supports both procedural and object oriented programming paradigm.      2】C supports top down approach. 2】C++ supports bottom top approach. 3】When we compared to C++ ,c is a subset of C++ 3】 C++ superset of c  4】C does not support object oriented programming paradigm. Therefore it has no support for polymorphism encapsulation and inheritance . 4】Baingan object oriented programming language c++ supports polymorphism encapsulation and inheritance. 5】In C data and functions are separate entities therefore the mapping between functions is different and complex. 5】In C++ data and functions are encapsulated together . Therefore the mapping between data and functions are easy. 6】In c data free entities and can be manipulted by the outside code . This is because of C does not support information hiding. 6】In C++ encapsulation hides the data to ensure that the data is used a

Concepts of OOPs

   Concept of Oop's( object oriented programming) Object oriented programming:- >>As the name suggested object oriented programing used objects in programming. >> object-oriented programming aims to implement the entities in programming. >> The basic aim of oops is to bind together and function the operation on them. So, that no other part of the code can access this data except that function. Basic concept (or) characteristics (or) features of oops . The following are characteristics of oops 1.Class 2.Object 3.Encapsulation 4.Data abstraction 5.Inheritance 6.Polymorphism 💥💥】1.Class【💥💥 The concept of class is always used to developing the user defined data. i] Class is a basic building block of object oriented programming. ii] class hold its own  data members and member functions which can accessd and used by creating an instant of the class. iii]Class is like a blueprint for an object. iv] whenever we define a class there is no memory space for data members a

Datatypes in C++

Image
  😘1.Datatype in C++ >>Datatype is a key word >>Its main purpose is to allocate the memory for variable. >> Datatypes specify the types of variable to be stored in the memory location. 】 Data types are three types  I】Primitive (or) fundamental (or) Bullet in the datatype. II】Derived data type. III】User defined data type. I】 Primitive Data types   It is the data type whose variables can store maximum 1 value.  Primitive data types are mainly 4 types : i]Integral data  ii]Float datatype data type  iii]Double datatype  iv]Character data type 😜 I ]Integral data 😜 >>It Can be identified with the keyword. >>It can you should the handle integer values >>Size of an entity type is 2 bytes Range of int data type is - 2 ^15 2 + 2 ^ 15-1.(-32,768 to+32,767).  ∆ Range represent the minimum and maximum value that are accepted by data type. Ex:-int a=5; 😳ii]Float datatype data type😳 >> It can be identified with a float keyword >> It can be used to

Applets

Image
 APPLET An applet is a small Internet-based program written in Java for the Web. It can be  downloaded by any computer. The applet is usually embedded in an HTML page on a Website and can be executed from within a browser. TYPES OF APPLETS: Local applet: A LOCAL applet is the one which is stored on our computer system. When browser tries to access the applet, it is not necessary for our computer to be connected to The Internet. Remote applet: A REMOTE applet is the one which is not stored on our computer system and we are required to be connected to the Internet. Applet life cycle : The applet lifecycle include the following methods: init(): This method is called to initialized an applet start(): This method is called after the initialization of the applet. stop(): This method can be called multiple times in the life cycle of an Applet. destroy(): This method is called only once in the life cycle of the applet when applet is destroyed Explanation: 1. An applet begins its life when the