Programming Using Java Unit 4 MCQ


Programming Using Java

Unit 4 MCQ


Programming Using Java


UNIT 4 MCQ OF PROGRAMMING USING JAVA


01. Java Source Code is compiled into ______________.


  1. Source Code
  2. Obj
  3. Exe
  4. Bytecode

Correct Answer: Bytecode


02. Which class provides stream to read binary data such as image etc. from the request object?


  1. ServltInputStream
  2. ServletOutputStream
  3. Both A & B
  4. None of the above

Correct Answer: ServletInputStream


03. Which of the following is used to interpret and execute Java Applet Classes hosted by HTML.


  1. appletshow
  2. appletviewer
  3. appletwatcher
  4. appletscreen

Correct Answer: appletviewer


04. Java servlets are an efficient and powerful solution for creating ………….. for the web.


  1. Dynamic content
  2. Static content
  3. Hardware
  4. Both a and b

Correct Answer: Dynamic content


05. Which is used for reading streams of raw bytes such as image data and for reading streams of characters, consider using FileReader?


  1. FileInputStream
  2. FileOutputStream
  3. Both A & B
  4. None of the above

Correct Answer: FileInputStream


06. The command javac is used to


  1. debug a java program
  2. compile a java program
  3. interpret a java program
  4. execute a java program

Correct Answer: compile a java program


07. Which method is used to change the name of a thread?


  1. public String getName()
  2. public void setName(String name)
  3. public void getName()
  4. public String setName(String name)

Correct Answer: public void setName(String name)


08. What will be the output of the program?


class PassA
{
public static void main(String [] args)
{
PassA p = new PassA();
p.start();
}

void start()
{
long [] a1 = {3,4,5};
long [] a2 = fix(a1);
System.out.print(a1[0] + a1[1] + a1[2] + " ");
System.out.println(a2[0] + a2[1] + a2[2]);
}

long [] fix(long [] a3)
{
a3[1] = 7;
return a3;
}
}{codeBox}

  1. 12 15
  2. 15 15
  3. 3 4 5 3 7 5
  4. 3 7 5 3 7 5

Correct Answer: 15 15


09. Java programs are


  1. Faster than others
  2. Platform independent
  3. Not reusable
  4. Not scalable

Correct Answer: Platform independent


10. What of the following is the default value of a local variable?


  1. null
  2. 0
  3. Depends upon the type of variable
  4. Not assigned

Correct Answer: Not assigned


Post a Comment