import java.util.Scanner;
public class Exam {
String s = "";
public static void main(String[] args) {
String [] questions = {
"Q-1. Class shoud be public or private ?",
"Q-2. To start MyClass, you would write? MyClass mc =",
"Q-3. An Interface can never be private or protected.",
"Q-4. A Vector class in jdk 1.2 is",
"Q-5. A String class is",
};
String [] answers = {
" 1) may be private 2) may be public 3) both 4) none of the above",
" 1) new MyClass(); 2) MyClass; 3) MyClass(); 4) new MyClass();",
" 1) True 2) False 3) Not valid 4) Depends on situation ).",
" 1) Public 2) Private 3) Final 4) Has only 1 constructor",
" 1) Final 2) Public 3) serielizable 4) 1 & 2",
};
int [] correct = {3,1,2,3,3};
int marks = 0;
int right = 0;
int wrong = 0;
System.out.println(" Enter the number of correct choice! 1,2,3 or 4.");
for(int i=0; i<correct.length; i++) {
System.out.println(questions[i]);
System.out.println(answers[i]);
Scanner interInteger = new Scanner(System.in);
int last = interInteger.nextInt();
if(last == correct[i]) {
marks += 4;
}
System.out.println("You obtained " +marks+ " Marks!");
System.out.println("Right Ans = " +right);
System.out.println("Wrong Ans = " +wrong);
}
}
No comments:
Post a Comment