Thursday, 28 February 2019

TCS XPLORE PROGRAMS 28-2-2019

PRINT LEAST ASCII VALUE CHARACTER
Main.java
public class Main{
public static void main(String []args){
String string="heLlo";
char ascii='z';
char[] strarray=string.toCharArray();
for(int i=0;i<strarray.length;i++)
if(ascii>strarray[i])ascii=strarray[i];
System.out.println(ascii);
}
}
Output: L
FILE HANDLING IN JAVA
Main.java
public class Main
{
public static void main(String[] args) {
Document obj1=new Document(1,"intro","intro_details",10);
Document obj2=new Document(2,"contents","contents_details",3);
Document obj3=new Document(3,"history","history_details",25);
Document obj4=new Document(4,"war","war_details",38);
Document arr[]={obj1,obj2,obj3,obj4};
combineDocument(arr);
}
public static void combineDocument(Document[] arrayobj){
int id=0,pages=0,arrlen=arrayobj.length;
System.out.println("id: "+(arrayobj.length+1));
System.out.println("Titles: "+arrayobj[0].getTitle()+"#"+arrayobj[1].getTitle()+"#"+arrayobj[2].getTitle()+"#"+arrayobj[3].getTitl
e());
System.out.println("Folders: "+arrayobj[0].getFolderName()+"@"+arrayobj[1].getFolderName()+"@"+arrayobj[2].getFolderName()
+"@"+arrayobj[3].getFolderName());
for(int i=0;i<arrayobj.length;i++)pages=pages+arrayobj[i].getPages();
System.out.println("Pages: "+pages);
}
}
Document.java
public class Document{
private int id;
private String title;
private String folderName;
private int pages;
public Document(int id,String title,String folderName,int pages){
super();

this.id=id;
this.title=title;
this.folderName=folderName;
this.pages=pages;
}
public int getId(){
return id;
}
public String getTitle(){
return title;
}
public String getFolderName(){
return folderName;
}
public int getPages(){
return pages;
}
}
Output:
id: 5
Titles: intro#contents#history#war
Folders: intro_details@contents_details@history_details@war_details
Pages: 76

2 comments:

ASP.NET Core: How to implement Azure Active Directory (AAD) Authentication in ASP.NET Core

  In this tutorial, we will implement security for ASP.NET Core Application using Azure Active Directory (AAD).  In this tutorial, I will co...