Java Programming OOPs
Questions 171 to 180
| 
Consider the following Java applet program: 
import java.awt.*; 
import java.applet.*; 
public
  class Applet1 extends applet { 
int
  i = 1, j = 2, k = 3, l = 4; 
boolean
  b = false; 
public
  void init() { 
i
  = j + 1; 
b
  = true; 
k
  = l - 2; 
} 
public
  void start() { 
j
  = i + 2; 
} 
public
  void stop() { 
j
  = k + 1; 
} 
public
  void destroy() { 
l
  = i + 5; 
} 
} 
Which of the following is the value of the variable i soon
  after the statement b = true and after pressing the restart option in
  the applet viewer? 
(a)
  1                        (b) 2                        (c) 3                        (d) 4                        (e) 5. | |||||||
| 
Consider the following program written in Java: 
class
  For{ 
public
  static void main(String args[]) 
{ 
for(int i=0; i<=2; System.out.println(i);); 
} 
} 
What would the output of the above program be when the
  program is executed? 
 | |||||||
| 
Consider the following Java program: 
class
  While{ 
public
  static void main(String args[]){ 
int
  x=0; 
while(x=<3)
  { 
System.out.println(x); 
if(x==2) 
continue; 
x++; 
} 
} 
} 
What would be the output of the above program if executed? 
 | |||||||
| 
Consider the following program written in Java: 
class
  Args{ 
public
  static void main(String args[]) { 
System.out.println(args[0]); 
System.out.println(args[1]); 
} 
} 
The above program is supplemented with the following
  command line assuming that the program has been compiled without any errors. 
java
  Args args zero one 
What would the output be? 
 | |||||||
| 
Consider the following program written in Java: 
class DoWhile{ 
public
  static void main(String args[]) 
{ 
int j=0; 
do{ 
int k=7; 
System.out.println(k); 
k+=7; 
j++; 
} 
while(j<3); 
} 
} 
What would be the output of the program if it is executed? 
 | |||||||
| 
Consider the following Java program: 
class
  Arr1{ 
public
  static void main(String args[]) { 
String[]
  Names={Sarma,Devi,Rakesh}; 
Names[2]=Ravi; 
for(int
  i=0;i<Names.length;i++) 
System.out.println(Names[i]); 
} 
} 
What would the output of the above program be if executed? 
 | |||||||
| 
Consider the following program written in Java: 
class Arr{ 
public static void main(String
  args[]){ 
int arr[]=new int[5]; 
for(int i=1;i<arr.length;i++) 
arr[i]=i; 
for(int j=0;j<arr.length;j++) 
System.out.println(arr[j]); 
} 
} 
What would the output of the program be if it is executed? 
 | |||||||
| 
Consider the following program written in Java: 
import java.awt.*; 
import java.applet.Applet; 
public
  class AwtEx extends Applet{ 
Checkbox
  ch1=new Checkbox("Advance Certificate"); 
Checkbox
  ch2=new Checkbox("Degree Certificate"); 
public
  void init(){ add(ch1); add(ch2); 
} 
} 
After compiling the program, the following set of codes is
  also written and saved separately by giving the name Awt.html. 
<applet code="AwtEx.class" height=100
  width=150> </applet> 
What would be the outcome when appletviewer is invoked by
  providing the file Awt.html? 
 | |||||||
| 
JAR File stands for 
(a)   Java 
  Runtime File                           (b)  Java Archive File 
(c)   Java Applet File                                                            (d)  Java Remote Method File 
(e)   Java applet Restart File. | |||||||
| 
Pick up the correct order of the life cycle of
  servlet : 
i.     Look up any
  HTTP information 
           Determine the browser version, host name of client,
  cookies, etc. 
ii.     Read any data sent by the user 
           Capture data submitted by an HTML form. 
iii.    Format the
  Results 
           Generate HTML on the fly 
iv.    Set the
  Appropriate HTTP headers 
           Tell the browser the type of document being returned or
  set any cookies. 
v.    Generate the
  Results 
           Connect to databases, connect to legacy applications, etc. 
vi.    Send the
  document back to the client 
(a)   ii,i,v,iii,iv,vi        (b) 
  i,ii,iv,iii,v,vi        (c)  i,ii,iii,v,vi,iv        (d)  ii,v,i,iv,vi,iii
  (e)  ii,v,i,iii,iv,vi. | 
Answers
| 
Answer :  (d) 
Reason : All other
  cases are not valid results. | |
| 
Answer :  (c) 
Reason : Declaration
  itself is incorrect. | |
| 
Answer :  (d) 
Reason : while
  condition syntax is incorrect. | |
| 
Answer :  (c) 
Reason : the output
  is args zero remaining all are contradictory to code | |
| 
Answer :  (b) 
Reason : very time k
  is initialized to 7 overwriting incremented values. Remaining all are
  incorrect. | |
| 
Answer :  (d) 
Reason : remaining
  all are incorrect. | |
| 
Answer :  (a) 
Reason : Choice A is
  the correct layout of the code. | |
| 
Answer :  (a) 
Reason : Choice A is
  the correct layout of the code. | |
| 
Answer :  (b) 
Reason : Remaining all
  JAR stands for Java Achieve, where as others specially different concepts of
  Java. | |
| 
Answer :  (a) 
Reason : The order of
  life cycle of servlet is choice a and the remaining all are incorrect | 
 
 
No comments :
Post a Comment