Java Topics

Tuesday, April 19, 2022

Typescript

 TypeScript Type

---------------------------------------------------

1) The TypeScript language supports different types of values

     TypeScript

                    1) Static Types

                           a) Built-in or Primitive Type

                           b) User-Defined DataType

                    2) Generics

                    3) Decorators

Static Types

-------------

1) Static Types mean "at compile time " or "without running a program."

2) Static types can be further divided into two sub-categories

         a) Built-in or Primitive Type

         b) User-Defined DataType

Built-in or Primitive Type

---------------------------------

     1) Number

     2) String

     3) Boolean

     4) Void

     5) Null

     6) Undefined

     7) Any Type


User-Defined DataType

----------------------------------

1) Array

2) Tuple

         (var userId : [number, String] = [1, 'USER001'];)

         (var Employee : [number, string, boolean] = [1, 'USER001', true];)

3) Interface

4) Class

5) Enums

6) Functions

number

-----------

1) The numeric data type can be used to represents both integers  and fractions.


demo 

        let first: number = 12.0;  //number

         console.log(first);        //12


2) TypeScript also supports Binary(Base 2),Octal(Base 8), Decimal(Base 10), and Hexadecimal(Base 16) literals.


string

----------


1) string literals is enclosing them in single or double quotation  marks.

2) It embedded the expressions in the form of $ {expr}.

demo

         let strVariable: string = " ";

         console.log(strVariable);          //empty

demo2 :

        let empName: string = "Jason Daniel";

        let empDept: string = "D&A";


        //Before-ES6


        let output1: string = empName + " works in the " +

                              empDept + "department.";

         console.log(output1);


          // o/p Jason Daniel works in the D&A department.


demo3 :

        let empName: string = "Jason Daniel";

        let empDept: string = "D&A";


        //After-ES6


        let output2: string = '${empName} works in the ${empDept} //with back-ticks

       department.'

        console.log(output2);


Note:


a) The variable values are written as ${ }.

b) Instead of writing a string that is a combination of text and  variables with concatenations,

we can use a single statement  with back-ticks ' (symbol under tidle and not single quote)


Boolean

--------------

1) Boolean data type can have only two values. They are "true" and  "false."


demo

        let isDone: boolean = false;

         console.log(isDone);


Void

----------


1) A void is a return type of the functions which do not return  any type of value


demo

        function helloUser(): void{

            console.log("This is a void message");

        }

        console.log(helloUser());


o/p


     This is a void message

      undefined


Note:

a) An undefined data type denotes uninitialized variable, whereas  null represents a variable whose value is undefined.


     let unusable: void = undefined;


 


demo:


     let tempNum: void = undefined;  //no value is assigned

      console.log(tempNum);

      tempNum = null;

      console.log(tempNum);


Null


--------


1) Null represents a variable whose value is undefined.

      let num: number = null;  //null value is assigned

      let bool: boolean = null;

      let str: string = null;


Undefined

-------------


1) The Undefined primitive type denotes all uninitialized variables in TypeScript and JavaScript


Any Type

------------

1) It is the "super type" of all data type in TypeScript

2) It is used to represents any JavaScript value


     


      let val: any = 'Hi';

      val = 555;  //Ok

      val = true; //Ok


 


Demo


      function processData(x: any, y: any) {

          return x + y;

          }

          let result: any;

          result = processData("Hello ", "Any!"); //Hello Any!

          console.log( "with string as any" + result);

          result = processData(2,3);

           console.log("with number as any" + result );


User-Defined DataType

----------------------------


   1) Array

   2) Tuple

   3) Interface

   4) Class

   5) Enums

   6) Functions


Array

--------------


1) An array is a collection of elements of the same data type

2) An array can be written in two ways:


           a) var list : number[] = [1,3,5];

           b) var list : Array<number> = [1,3,5];


                              //generic array type


Demo


          var list : Array<number> = [1,3,5];


          console.log ("index of zero" + list[0]);


          console.log ("index of two" + list[2]);


 


Tuple

---------------


1) The Tuple is a data type which includes two sets of values of  different data types.


demo


var employee: [number, string] = [1, "steve"];

console.log("Employee number : " + employee[0]);


 


Inheritance

---------------

1) TypeScript classes can be extended to create new classes with  inheritance, using the keyword 'extends'. (Adv. class can inherite multiple classes,interfaces. Interface also inherit classes )


Demo


class Person {


  name: string;


    constructor(name: string) {


      this.name=name;


}


}


class Employee extends Person {


empCode: number;


  constructor(empCode: number, name: string) {


    super(name);


      this.emoCode = empCode;


    }


 


class Implement multiple Interface

------------------------------------------


Demo

interface IPerson {


name: string;


display(): void;


}


interface IEmployee {


   empCode: number;


}


class  Employee implements IPerson,IEmployee {


empode: number;


name: string;


constructor(empcode: number, name:string) {


    this.empCode = empCode;


    this.name = name;


}

display(): void {


 

TypeScript - abstract Class

----------------------------------


1) TypeScript allows us to define an abstract class using keyword   abstract.

2) Abstract classes are mainly for inheritance where other classes may derive from them.

3) We cannot create an instance of an abstract class.

4) An abstract class typically includes one or more abstract , methods or property declarations.

5) The class which extends the abstract class must define all the abstract methods.


Demo

abstract class APerson{

   name: string;

   constructor(name:string){

       this.name = name;

  }

display(): void{

        console.log(this.name);

}

abstract find(string): void;

find(name:string):void{

console.log("welcome :" +name);

}

}

let emp:Employee = new Employee("James", 100);

emp.find('Steve');

emp.display();


TypeScript - Data Modifiers or Access Modifiers

-----------------------------------


public - visible to all (no restriction)


private - visible to within the class(own)


protected - visible to own and derived classes


===============================================================================================


1) The concept of 'Encapsulation' is used to make class members    public or private

2) class can control the visibility of its data members.This is done using access modifiers.

3) There are three types of access modifiers in TypeScript:  public,private and protected.

public

----------

1) By default, all members of a class in TypeScript are public.

2) All the public members can be accessed anywhere without any restrictions.


emp.empCode = 123;


emp.empName = "Jason Daniel";


console.log("Employee code : " + emp.empCode);


console.log("Employee name : " + emp.empName);


private

--------------

demo


      class Employee{


         private empCode: number;


         empName: string;


           display():void{


                console.log("private empCode : " +this.empCode);


          }

          }

               let emp = new Employee();


                   //emp.empCode = 123; // compiler Error


               emp.empName = "HCL"; //OK


                 emp.display();


protected

------------


1) Te protected access modifier is similar to the private access  modifier, except that protected members can be accessed using their deriving classes.


Demo

export{}


class Employee{


public empName: string;


   protected empCode: number;


  constructor(name: string,code: number){


    this.empName = name;


    this.empCode = code;


}


}


class SalesEmployee extends Employee{


Saturday, February 26, 2022

Core Java

Java Full Course

Java is a high-level programming language developed by Sun Microsystems and released in 1995. Java is guaranteed to be Write Once, Run Anywhere. Java is used to develop mobile apps, web apps, desktop apps, games and much more.

                                                Java is an object-oriented, class-based, concurrent, secured and general-purpose programming language. JAVA is platform-independent language. It is not specific to any processor or operating system.

To Know more details for Java Click here.

In this course we cover all the topics like Fundamentals of Java, Oops, Collections Framework, Basic programs and latest Interview Questions from different Organizations.

You can Click here to know the list of Topics here.

The primary objective of Java programming language creation was to make it portable, simple and secure programming language. The features of Java are also known as java buzzwords. Click here to know more details of it.

How to install Eclipse in your machine?

To install Eclipse in your machine you can follow this link to Click here


Oracle SQL

✓SQL means structured query language.

✓ Basically we can say SQL is a language which is used to interact with database.

✓With help of SQL queries we can able to perform read, insert,update and delete operations in the database tables and data.

✓ SQL is case insensitive language.

For more details about each topics, Click on each link below.

  1. SQL Statements:
  2. Operators & OrderByClause
  3. Functions & Aliases
  4. Like Operator & Wildcards
  5. Joins
  6. Keys In DBMS

JDBC

 Jdbc( Java database connectivity)


✓It helps to achieve the connectivity between Java and database.

✓Hibernate also make use of jdbc to interact with database.

✓If we have a web application and if it has a database, then it needs to interact with database to read or modify the data.

✓ Jdbc helps to do this and in the world of Java, jdbc is the one and only API that helps to interact with rdbms(DB) applications.

✓ Jdbc is DB dependent i.e. using Jdbc we can interact with any rdbms applications exist in the world( like Oracle, mySQL,DB2, Sybase etc).

✓"java.sql.*" is the package representation of jdbc.

✓ Any class/interface belongs to this package means it's part of jdbc.



Below are the necessary steps to work with jdbc:


1. Load the driver

2. Get the DB connection via driver

3. Issue SQL queries via connection

4. Process the results returned by SQL Query

5. Close all jdbc connections


Note:

✓ All these steps are mandatory

✓ All these steps are interdependent


Driver:


✓ Drivers are external software component required by jdbc to interact with RDBMS application.

✓ Drivers are provided by DB vendor and they are DB dependent.

✓ Using MySQL driver we can only interact with mySQL RDBMS application and using DB2 driver we can only interact with DB2 RDBMS application.

✓ Drivers, as the name implies acts like a bridge between Java application and RDBMS application.

✓ DB vendor provides the driver class in the form of JAR file.


Steps to load the Driver class into the program:


There are two ways to load the Driver class.


1. By invoking "registerDriver()" method present in "java.sql.DriverManager" class by passing an instance of "Driver" class.


Syntax: public void DriverManager.registerDriver(java.sql.Driver driverref) throws sqlException


ex: java.sql.Driver ref = new com.mysql.jdbc.Driver();

DriverManager.registerDriver(ref);


2. Load the Driver class with the help of java's "class.forName()" .


ex: class.forName("com.mysql.jdbc.Driver").new instance();


Driver types:


There are four types of Drivers.


1. Type 1 : JDBC-ODBC Bridge

2. Type 2 : Native-API Driver

3. Type 3 : Network- protocol Driver

4. Type 4 : Native protocol Driver


DB URL:


✓ database uniform resource locator.

✓ As the name implies, it uniquely identifies database or rdbms application in the network.

✓ the structure of DB URL looks like below

<protocal> :<sub protocol>: <sub name>

✓ it is case in-sensitive.


1. Protocol:

     i. It is mandatory information and case insensitive.

    ii. In case of Java/J2EE protocol is always "jdbc".


2. Sub protocol:

   i. It is mandatory information and case insensitive.

  ii. This information is provided by DB vendor and we have to refer the driver manual to get this information.

iii. In case of MySQL, sub protocol is "MYSQL" but in case of Oracle or DB2 it is different.


3. Sub name:

    i. It's mandatory information.

    ii. It consists of,

  • Host Name ( computer name or IP address and case-insensitive)

• port number( should be in digits)- it uniquely identifies an application in an Operating System.

• database name/schema name

• username and password( case sensitive)


Jdbc URL examples:


oracle: 

 jdbc:oracle:thin:myuser/mypassword@myserver:1521:mydb


MySQL:

jdbc:mysql://myserver:3306/mydb?user=myuser& password=mypassword


DriverManager:


✓ DriverManager is a concrete class present in jdbc API and as the name implies, it manages the Driver.

✓ It helps Java program to connect with database and for that it requires below following information.

i. Driver class    ii. DB URL


✓ By invoking "registerDriver()" method on DriverManager we can provide an object of Driver class.

✓ By invoking "getConnection()" method on DriverManager we can provide DB URL.

✓ DriverManager as overloaded version of getConnection() method, they are


i. Connection getConnection (String dbUrl) throws SQLException


ex: String dbUrl="jdbc.mysql://localhost:3306/dbname?user=root& password=root";

Connection con= DriverManager.getConnection(dbUrl);


ii. Connection getConnection (String dbUrl, String user, String password) throws SQLException


ex: String dbUrl = "jdbc:mysql://localhost:3306/dbname?";

String user="root";

String password="root";


iii. Connection getConnection (String dbUrl, Properties props) throws SQLException


ex: String dbUrl = "jdbc:mysql://localhost:3306/dbname?";

String filePath="D:\\db.properties";

FileReader reader = new FileReader ("filePath");

Properties props = new Properties ();

props.load(reader);


Connection con=DriverManager.getConnection(dbUrl,props);


Results of RDBMS application:


✓ whenever we issue "select SQL queries" to database it returns DB results.

✓ whenever we issue "other than select SQL queries" to database then it returns "number of rows affected count" in the form of integer.

✓ Hence, based on the results we can group SQL queries into two groups.


   i. Select SQL query

   ii. other than select SQL query


1. Static SQL queries:


  Any SQL queries "without conditions"/" all conditions with hardcoded values" are called as "static SQL queries".


ex:

   • select * from table;

   • select * from table where x=1;

   • insert into table (Id, name) values (1,'vijay');


2. Dynamic SQL queries:


   Any SQL queries which must have conditions and one/more conditions value get decided at run time are known as "Dynamic SQL queries".


ex:

   • select * from table where x=? and y=?;

Rest API

SpringBoot

Tomcat

Tomcat is an web server which is used to run our web applications. Tomcat server is an open source/free software and anyone can download from the official Tomcat website from the Browser.

Step by Step guide to setup tomcat server in our local system:

1. Download Tomcat server from below official website

    https://tomcat.apache.org/

  Click on Tomcat9.0 from left side ----> then select "32-bit/64 bit Windows Service Installer(pgp,sha512)" as below.

      


2. Once the file is downlaoded, extract the "apache-tomcat-9.0.59-windows-x64.zip" file in your local system.

3. Goto bin folder-----> open startup.bat.

        


4. You can see below console will open that the tomcat server has been started.

       


5. Open the below URL in browser to verify whether tomcat server is up and running fine. If you see below window, that your tomcat server is running fine.

    


6. To stop Tomcat server, click on shutdown.bat under bin folder in your local system.

     



7. Suppose, if you want to test your code changes with the new .war file, you can place that .war file under "webapps" folder and run the startup.bat script and test your changes.

Below are the different issues we may experience while setting up tomcat server and find the solutions below to fix the issues.

1. Once you run startup.bat file, the window/console will open for 1 0r 2 secs and closes immediately.

   Solution: You need to add environment variables as below.

     Right click on This PC---->select Properties -----> click on Advanced System settings ----> Go to Environment Variables. Set the varibales as shown in below screenshots.

       i. First set  "CATALINA_HOME" under "User varibales" as below and copy the path/value before bin folder.

        


        ii. Then, add "JAVA_HOME" path under "System Variables" as below. 

                


      iii. Set the jdk path (copy the jdk path till bin folder) in "Path" feild under "System Variables" as below ---> click "Ok" to save.

               


  2. Getting "java.net.BindExcpetion: address already in use: JVM_BIND" error.

      Solution : We are getting this error due to the previous process/session is still running and we need to kill that pid.

   Open CMD(command Prompt) as "Run as administaror " and type the below commands.

    i. First type below highlighted command to get the pid's running for the port number which you are using.

             


ii. Here i don't have any pid's, if you find any pid's kill them using below command.

             

               In above screenshot, 1234 is your pid
           




Angular

ANGULAR CURRICULUM


Angular Basics:

Angular Directives :

  1. Angular Directives
  2. Angular ngIf Directive
  3. Angular ngStyle Directive

Angular Databinding :

  1. Angular Databinding
  2. Angular String Interpolation
  3. Angular Event Binding

Angular Pipes :

  1. Angular pipes

Angular Error Fixing :

  1. Angular Error Fixing

Angular Forms :

  1. Angular Forms
  2. Data Flow in Angular Forms
  3. Angular Reactive Forms

Angular Service :

  1. Angular Service Introduction
  2. Angular Dependency Injection
  3. How to create a Service
  4. Service Real-time Scenario
  5. Angular Callbacks

Angular Http Service :

  1. Getting Data
  2. Creating Data
  3. Updating Data
  4. Deleting Data
  5. OnInitInterface Extracting
  6. Handling Errors
  7. Observables vs Promises
  8. Handling Unexpected Errors
  9. Handling Expected Errors

Template-Driven Forms :

  1. Types of Forms
  2. ngModel
  3. Adding Validation
  4. Specific Validation Errors
  5. Styling Invalid Input Fields
  6. Cleaner Templates
  7. ngForm
  8. ngModelGroup
  9. Control Classes and Directives
  10. Disabling the Submit Button
  11. Working with Check Boxes
  12. Working with Drop-down Lists

Reactive Forms :

  1. Creating Controls Programmatically
  2. Adding and Handling Validations
  3. Asynchronous Operations
  4. Asynchronous Validation
  5. Nested FormGroups
  6. FormArray

Routing And Navigation :

  1. Configuring Routes
  2. RouterOutlet
  3. RouterLink
  4. RouterLinkActive
  5. Route Parameters
  6. Multiple Parameters
  7. Query Parameters
  8. Subscribing Observables
  9. SwitchMap Operator
  10. Programmatic Navigation

Pilot Project Angular + Spring :

  1. CRUD Example
  2. File Upload Example
  3. Login & Logout Example
  4. Search Field Example

Angular Interview Q & A 





Maven

Jenkins

Eclipse Overview

Docker

Notes

WinScp tool

  •  Winscp tool is an user friendly software to download and upload the files easily from your local system to linux servers easily.
  • In Linux, if you want to download or upload any file, we need to work with commands. But, using WinScp tool we can download or upload or change the permissions of a file or remove/delete the files easily.

How to use WinScp tool?

 
  • First download the WinScp tool using below URL. 

  • Once the file(.exe file) is downloaded, install the software just by double clicking on that file.
  • After successfully installed the Winscp, Open and it looks like below.
                         

  • Enter the linux server details as below and click on Login.
                      Hostname : Linux server name
                      User name : enter uername
                       Password: enter password for above server
  • Here, left side represents your local system and right side represents your linux server.
  • If  you want to download an file from linux to local. Follow the below steps.
                    Navigate to the directory/path in Linux server(i.e. at right side) from where you want to download the file ---> Right click on File---->Download--->Browse local path where you want to copy--->click on "OK".

  • If you want to upload an file from your local machine to Linux server. Follow the below steps.
               Navigate to the directory/path in your local system(i.e. at left side) from where you want to upload the file ---> just drag that file from your local to linux server(i.e. drag file from left to right side) and it will upload the file to linux server in the selected path.

  • To update/modify the permissions of an file. Follow the below steps.
               Right click on the File--->Select Properties--->Under Permissions, you can check/uncheck the read or write access ----> click on "OK" to save the changes.



Kubernetes

Postman

Linux/Unix Course

 ✓Linux is one type of operating system.

✓ It is open source platform.

✓ It is a command line interface I.e. we have to use commands to interact with the Linux operating system.

Versions of Linux:

 We have different versions of Linux operating system as below,

  • RedHat
  • Kali
  • Slackware
  • Debian
  • Archlinux
  • Solaris
  • Ubuntu
  • Fedora

✓ To work with the Linux/Unix servers we have to download putty software.

✓ Linux commands are case sensitive.

Basic commands used to deal with linux:

1. pwd( print current working directory):

    It prints the current directory name with the complete path.

Command: pwd

2. ls(list):

     It gives the list of files present in current directory.

Command: ls -lrt

✓ to display hidden files, use below command.

  Command: ls -a

✓ to display the file size in human readable format.

 Command: ls -lh

3. cd(change directory):

To move or navigate from one to another directory.

Command: cd directory_name

example: cd /ct-app/logs

4. touch:

      To create an Empty file in a directory.

Command: touch file_name

example: touch sample.txt

5. vi:

    To edit/ write the content in a file.

Command: vi file_name

Steps

i. enter the below command to open the file.

    command: vi file_name

ii.press "i" from keyboard to enter into insert mode.

iii. write/edit the content in a file

iv. press "esc"  button from keyboard to comeout from insert mode.

v. to exit with save,use below command.

  command: :wq!

vi. to exit without save, use below command.

 command: :q!

6. cat / view :

 To view the file, we can use either cat or view command as below.

command: view file_name

command: cat filename

7. rm:

  ✓To remove the single file from a directory.

command: rm filename

✓ To remove multiple files at a time, use below command.

 command: rm filename1, filename2,filename3

8. mkdir:

   To create an directory use below command.

  command: mkdir directoryname

  ex: mkdir Vijay

9. rmdir:

  ✓ To delete empty directory.

 command: rmdir directoryname

 ✓To remove the directory which contains files.

command: rm -r directoryname

10. To list the java processes running on Linux server.

command : top

11. To check the status of single process ID.

  command: ps -ef | grep -i pid

example : ps -ef | grep -i 145

12. mv(move):

    To move the file data from one file to another file( data from file1 moved to file2).

 command : mv file1 file2

13. cp(copy):

   To copy the file data from one file to another file(copies from source(file1) to destination (file2) file).

command: cp file1 file2

14. To search for an specific pattern in a file.

  command: grep "vijay" filename

15. To unzip the file in an directory

command: unzip filename.zip

16. To change simulink

  command : ln -sfn /ct-app/logs logs

17. To serach for a particular string on linux server using "find" command.

✓The below command search for the string "Vijay" in all the paths on linux server.

command: find . -type f - exec grep -i "Vijay" { } +

18. To know the Java version on Linux server.

command: Java -version

19. To know the Java path which set in batch profile script.

 command : vi ~/.bash-profile

20. To unzip tar file in a directory

command: tar -xvf filename.tar

21. To come back one step from the current directory.

command: cd ..

22. To come back two steps from the current directory.

   command: cd ../..

23. To kill the pid on a server.

     command : kill -9 pid

24. To remove complete line in a file, press letter "d" twice at a time.

     command: dd

25. To search for an special characters in an XML file on linux server, use below command.

  command: /[^<]

Note:

  In your linux server, you don't know from where JRE_HOME path is reading and need to update to latest version.

  Solution : Once you login to the server, type below command. You can see JRE_HOME path over there and you can update it and save the changes and close the server and login again. You can see now your JRE_HOME will be pointing to new version.

       command : vi ~/.bash_profile


For More Information Click below links here:


HTML 5 & CSS 3

 HTML :

✓ HTML means hypertext markup language.

✓ HTML is used to display the data in browser.

✓HTML is case insensitive language.

✓ HTML defines the structure of web page.

Note: There is no value for whitespace

ex :

         <! Doctype html>

        <html>

        <head>

        <title> Title of Webpage</title>

        </head>

        <body>

         <h1> High Importance</h1>

         <p> paragraph</p>

         </body>

         </html>

Description about above tags :

-> <!Doctype html> : Describes that HTML5 document

-> <html> : Root element of HTML page

-> <head> : Contains meta information of HTML page

-> <title> : Specifies title for an HTML page

-> <body> : Whatever we write within body tag, it will display in browser 


HTML attributes:

✓src : Defines path to the image to be displayed.

✓href: Defines URL of the page link goes to.

✓alt : Gives alternative text to the image i.e. some brief description about image in case it is not visible.

✓width, height : Gives height and width of the image.

✓style : Used to add styles to an element.

✓ lang : Defines language of the web page.

ex:

  i) <a href="https://tvstreetechnologies.blogspot.com/2022/02/html-5-css.html"> Visit Vijay blog</a>

ii)<img src="VijayBlogPost.jpg" alt="Vijay blog about techonlogies" width="500" height="500">

iii) <br> : to add line break or space

Go to below  links ,to learn complete course of HTML 5 & CSS3


Lesson1

Lesson2

Lesson3







GitHub

 In vsCode -> clone -> https://----------------/----.git


github config --global user.name "Tammineni Simha"

github config --global user.email "tammineni.simha@rbccm.com"


git config --global http.sslVerify false


credential manager -&gt; windows credential -&gt;update password


Environment Setup Notes:


Edit environment variables for your account


For Java:


In System variables:

--------------------


variable name:JAVA_HOME

variable value:C:\Users\vijay\java\jdk-1.8


Edit path:%JAVA_HOME%


For Maven:


In System variables:

--------------------


variable name:MAVEN_HOME

variable value:C:\Users\vijay\apache-maven-3.8.1\bin


Edit path:%MAVEN_HOME%


For Angular:


In User Variables :

--------------------

->path -->

C:\Program Files\nodejs\

C:\Users\Vijay\AppData\Roaming\npm

C:\Users\Vijay\AppData\Roaming\npm\node_modules\@angular\cli\bin


In System Variables:

----------------------


Edit Path:%AppData%\npm


For Proxy:


In System Variables -> click new and add HTTP_PROXY,HTTPS_PROXY in variable and link in value place add it


variable name:HTTP_PROXY

variable value:http://<username>:<Password>@cmusproxy.oak.fg.rbc.com:8080

  

                       &

variable name:HTTPS_PROXY

variable value:http://<username>:<Password>@cmusproxy.oak.fg.rbc.com:8080