How to create ContentNote and Link it to records in Salesforce?

Sample Code:
ContentNote objCN = new ContentNote();
objCN.Title = 'Test';
objCN.Content = Blob.valueOf( 'Testing Content' );
insert objCN;

ContentDocumentLink objCDL = new ContentDocumentLink();
objCDL.ContentDocumentId = objCN.Id;
objCDL.LinkedEntityId = '0018c00002H4wSIAAZ';//Hard coded account Id
insert objCDL;
 
Output: