Questions

 import java.lang.*;

import java.io.*;

class Questions{

public String [][]qpa; public String[][]qca; 

Questions()throws IOException

{

qpa=new String[10][5];

//questionsandobjectives//

DataInputStream in=new DataInputStream(System.in);

qpa[0][0]="1.which of the following options leads to the portability and security of java?"; qpa[0][1]="1.Bytecode is executed by JVM"; qpa[0][2]="2.The applet makes the java code secure and portable"; qpa[0][3]="3.use of exception handling";qpa[0][4]="4.Dynamic binding between objects";


qpa[1][0]="2.which of the following is not a java features"; qpa[1][1]="1.Dynamic";

qpa[1][2]="2.Architecture neutral"; qpa[1][3]="3.object oriented";

qpa[1][4]="4.use of pointers";


qpa[2][0]="3.Which keyword is used for accessing the features of a package"; qpa[2][1]="1.package";

qpa[2][2]="2.import";

qpa[2][3]="3.extends";

qpa[2][4]="4.export";


qpa[3][0]="4.which package contains the random package"; qpa[3][1]="1.java.lang package";

qpa[3][2]="2.java.util package";

qpa[3][3]="3.java.awt package";

qpa[3][4]="4.java.io package";


qca=new String[10][2];

//questionsandcorrectanswers//

qca[0][0]="1.which of the following options leads to the portability and security of java?"; qca[0][1]="1.Bytecode is executed by JVM";


qca[1][0]="2.which of the following is not a java features?";

qca[1][1]="4.use of pointers";


qca[2][0]="3.Which keyword is used for accessing the features of a package"; qca[2][1]="2.import";


qca[3][0]="4.which package contains the random package"; qca[3][1]="2.java.util package";

}

}

public class qu{

public static void main(String[]args)throws IOException{ 

DataInputStream in=new DataInputStream(System.in);

int x,correct=0,wrong=0,i,j; 

String ans[]=new String[10];

Questions q=new Questions(); System.out.println("JAVA QUIZ"); System.out.println(" ");

//forlooptodisplayquestionandreadtheanswerfromtheuser//

for(i=0;i<4;i++){

for(j=0;j<5;j++){

System.out.println(q.qpa[i][j]);

}

System.out.println("youranswer:");

 

x=Integer.parseInt(in.readLine()); ans[i]=q.qpa[i][x];

}


//calculatecorrectanswers//

for(i=0;i<4;i++){

if(q.qca[i][1].equals(ans[i]))correct++;

 else

wrong++;

}

 

//printingthecorrectanswersanduserselectedanswers// System.out.println("CORRECT ANSWERS");

for(i=0;i<4;i++){

System.out.println(); System.out.println(q.qpa[i][0]); System.out.println("correctanswer:"+q.qca[i][1]); System.out.println("youranswer:"+ans[i]);

}

System.out.println("Correct="+correct+"\twrong="+wrong);

}

}


OUTPUT:

JAVA QUIZ

 

1.which of the following options leads to the portability and security of java?

1.Bytecode is executed by JVM

2.The applet makes the java code secure and portable

3.use of exception handling

4.Dynamic binding between objects

youranswer:

1

2.which of the following is not a java features

1.Dynamic

2.Architecture neutral

3.object oriented

4.use of pointers

youranswer:

2

3.Which keyword is used for accessing the features of a package

1.package

2.import

3.extends

4.export

youranswer:

2

4.which package contains the random package

1.java.lang package

2.java.util package

3.java.awt package

4.java.io package

youranswer:

2


1.which of the following options leads to the portability and security of java?

correctanswer:1.Bytecode is executed by JVM

youranswer:1.Bytecode is executed by JVM


2.which of the following is not a java features

correctanswer:4.use of pointers

youranswer:2.Architecture neutral


3.Which keyword is used for accessing the features of a package

correctanswer:2.import

youranswer:2.import


4.which package contains the random package

correctanswer:2.java.util package

youranswer:2.java.util package

Correct=3 wrong=1


=== Code Execution Successful ===

Comments