jamsi
question
3 Answer(s)      a year and 2 months ago
Posted in : Java Interview Questions

Dear Sir ,

could you please send me programmatic type ( to find out result from the given Java code ) Core Java interview questions It's very urgent I have interviews , please send me as soon as possible.

View Answers

March 24, 2012 at 5:40 PM


import java.util.*;
class Student{
    String name;
    int marks1;
    int marks2;
    int marks3;
    int average;
    Student(String name,int marks1,int marks2,int marks3,int average){
    this.name=name;
    this.marks1=marks1;
    this.marks2=marks2;
    this.marks3=marks2;
    this.average=average;
    }
    public String getName(){
        return name;
    }
    public int getMarks1(){
        return marks1;
    }
    public int getMarks2(){
        return marks2;
    }
    public int getMarks3(){
        return marks3;
    }
    public int getAverage(){
        return average;
    }
}
class StudentEx 
{
    public static void main(String[] args) 
    {
        Scanner input=new Scanner(System.in);
        ArrayList<Student> list=new ArrayList<Student>();
        for(int i=0;i<25;i++){
            System.out.print("Enter Name: ");
            String name=input.next();
            System.out.print("Enter Marks1: ");
            int m1=input.nextInt();
            System.out.print("Enter Marks2: ");
            int m2=input.nextInt();
            System.out.print("Enter Marks3: ");
            int m3=input.nextInt();
            int total=m1+m2+m3;
            int av=total/3;
            list.add(new Student(name,m1,m2,m3,av));
        }
        for(Student st:list){
            System.out.println(st.getName()+"\t"+st.getAverage());
        }
    }
}

March 24, 2012 at 5:40 PM


import java.util.*;

class StudentData{
    int id;
    String name;
    int marks;

    StudentData(int id,String name,int marks){
        this.id=id;
        this.name=name;
        this.marks=marks;
    }
    public int getId(){
        return id;
    }
    public String getName(){
        return name;
    }
    public int getMarks(){
        return marks;
    }

    public static void main(String[] args){
        int count=0;
        LinkedList<StudentData> list=new LinkedList<StudentData>();
        Scanner input=new Scanner(System.in);

        for(int i=0;i<5;i++){
            System.out.print("Enter ID: ");
            int id=input.nextInt();
            System.out.print("Enter Name: ");
            String name=input.next();
            System.out.print("Enter Marks: ");
            int m=input.nextInt();

        list.add(new StudentData(id,name,m));
        }

       for(StudentData data:list){
            if(data.getMarks()>=60){
                count++;
            }
       }
       System.out.println("Number of students obtained 60 or above: "+count);

        System.out.print("Enter id to display record: ");
        int rec=input.nextInt();
        for(StudentData data:list){
            if(data.getId()==rec){
            System.out.println(data.getId()+"\t"+data.getName()+"\t"+data.getMarks());
            }
        }
    }
}

March 24, 2012 at 5:41 PM










Related Pages:
question
question   sir plz tell me what should i give in title box. just i want java program for the question typed in this area
question
question   sir plz tell me what should i give in title box. just i want java program for the question typed in this area
Question
Question   When there is an exception in my program how java runtime system handles
question
question  dear sir/madam my question is how to compare two text format in java..we are java beginners..so we need the complete source code for above mentioned question...we have to compare each and every word
question
question  Dear sir i had some typing mistake at previous question so its my humble request to let me know the steps to start the tomcat6 under the tomcat directory
question
question  Gud morning sir, I have asked u some question regarding jsp in saturaday for that i didnot find any answere in which u send me the some of the links.U have asked me the specify some details. There is a entity name
Question?
Question?  My question is how to: Add a menu bar to the program with a File menu. In the File menu, add a submenu (JMenuItem) called About. When the user clicks on the About menu item, display a JOptionPane message dialog

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.