Can be done in these simple step.
Step 1.
Create a Class with all the variables you need
Step 2.
Create a constructor with all the variables as parameter, like
className(String name,int rollNUmber){
this.name=name;
this.rollNumber=rollNumber;
}
Step 3
Execute this query
select new com.path.ClassName(columnName1,columnName2) from tableName where Conditions;
NB They type of the value returned(column) from the query must fit into the constructor argument.