Niik P.

asked • 01/26/22

Ans is not matched! all answer in write in incorrect answer

import java.lang.System;

import java.lang.String;

import java.io.*;

import java.util.Scanner;


class Que_6

{

public static void main(String Args[]) throws IOException

{

String username ="";

String password ="";

String ans1,ans2,ans3,ans4,ans5,ans6,ans7,ans8,ans9,ans10;

char choice;

int i=0;

int x=0;

do

{

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

Scanner s = new Scanner(System.in);

System.out.println("1. USER");

System.out.println("2. ADMIN");

System.out.println("3. EXIT!");

System.out.print("Enter Your Choice: ");

x = Integer.parseInt(br.readLine());

switch(x)

{

case 1:

System.out.print("USER");

System.out.print("\nUsername: ");

username = br.readLine();

System.out.print("Password: ");

password = br.readLine();

break;

case 2:

System.out.println("ADMIN");

break;

case 3:

System.out.println("EXIT!");

System.exit(0);

default:

System.out.println("Invalid Choice!");

}

System.out.println("\n1. Number of primitive data type in Java?");

System.out.println("\nA. 6 \nB. 7 \nC. 8 \nD. 9");

do

{

System.out.print("\nAns: ");

ans1 = br.readLine();

}while(ans1 == "C");

if(ans1 == "A" || ans1 == "B" || ans1 == "D")

{

System.out.println("Incorrect Answer!");

}

System.out.println("\n2. What's the size of float and double in Java?");

System.out.println("\nA. 32 and 64 \nB. 32 and 32 \nC. 64 and 64 \nD. 64 and 32");

do

{

System.out.print("\nAns: ");

ans2 = br.readLine();

}while(ans2 == "B");

if(ans2 == "A" || ans2 == "C" || ans2 == "D")

{

System.out.println("Incorrect Answer!");

}

System.out.println("\n3. Select the valid Statement...");

System.out.println("\nA. char[] ch = new char(5) \nB. char[] ch = new char[5] \nC. char[] ch = new char() \nD. char[] ch = new char[]");

do

{

System.out.print("\nAns: ");

ans3 = br.readLine();

}while(ans3 == "A");

if(ans3 == "B" || ans3 == "C" || ans3 == "D")

{

System.out.println("Incorrect Answer!");

}

System.out.println("\n4. Array in Java are-");

System.out.println("\nA. Objects \nB. Object Refrences \nC. Primitive Datatypes \nD. None");

do

{

System.out.print("\nAns: ");

ans4 = br.readLine();

}while(ans4 == "A");

if(ans4 == "B" || ans4 == "C" || ans4 == "D")

{

System.out.println("Incorrect Answer!");

}

System.out.println("\n5. What is the object created with new keyword?");

System.out.println("\nA. At run time \nB. At compile time \nC. Depends on code \nD. None");

do

{

System.out.print("\nAns: ");

ans5 = br.readLine();

}while(ans5 == "A");

if(ans5 == "B" || ans5 == "C" || ans5 == "D")

{

System.out.println("Incorrect Answer!");

}

System.out.println("\n6. In which of the following is toString() method defined?");

System.out.println("\nA. java.lang.object \nB. java.lang.String \nC. java.lang.util \nD. None");

do

{

System.out.print("\nAns: ");

ans6 = br.readLine();

}while(ans6 == "A");

if(ans6 == "B" || ans6 == "C" || ans6 == "D")

{

System.out.println("Incorrect Answer!");

}

System.out.println("\n7. compareTo() returns-");

System.out.println("\nA. True Value \nB. False Value \nC. An int Value \nD. No Value return");

do

{

System.out.print("\nAns: ");

ans7 = br.readLine();

}while(ans7 == "C");

if(ans7 == "A" || ans7 == "B" || ans7 == "D")

{

System.out.println("Incorrect Answer!");

}

System.out.println("\n8. To which of the following does the class string belong to...?");

System.out.println("\nA. java.lang \nB. java.awt \nC. java.applet \nD. java.String");

do

{

System.out.print("\nAns: ");

ans8 = br.readLine();

}while(ans8 == "A");

if(ans8 == "B" || ans8 == "C" || ans8 == "D")

{

System.out.println("Incorrect Answer!");

}

System.out.println("\n9. Total constructor string class have?");

System.out.println("\nA. 3 \nB. 7 \nC. 13 \nD. 20");

do

{

System.out.print("\nAns: ");

ans9 = br.readLine();

}while(ans9 == "C");

if(ans9 == "A" || ans9 == "B" || ans9 == "D")

{

System.out.println("Incorrect Answer!");

}

System.out.println("\n10. Output of Math.floor(3.6)?");

System.out.println("\nA. 3 \nB. 3.0 \nC. 4 \nD. 4.0");

do

{

System.out.print("\nAns: ");

ans10 = br.readLine();

}while(ans10 == "B");

if(ans10 == "A" || ans10 == "C" || ans10 == "D")

{

System.out.println("Incorrect Answer!");

}

System.out.println("1. "+ans1+"\n2. "+ans2+"\n3. "+ans3+"\n4. "+ans4+"\n5. "+ans5+"\n6. "+ans6+"\n7. "+ans7+"\n8. "+ans8+"\n9. "+ans9+"\n10. "+ans10);

System.out.print("\nDo You Want To Continue For Next User Give Test!(Y/N): ");

choice = s.next().charAt(0);

}while(choice == 'Y'|| choice == 'y');

if(choice == 'N'||choice == 'n')

System.out.println("The End!");

}

}

//Ans: C A B A A A C A C B

1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.