AMITI PAPER ON 18th OCTOBER

Previous Years Questions

 

AMITI PAPER ON 18th OCTOBER

Hi
1) What wil the o/p:
class Base{private void amethod(int iBase)

{System.out.println(“Base.amethod”);
}
}
class Over extends Base{
public static void main(String argv[]){
Over o = new Over();
int iBase=0;
o.amethod(iBase);
}
public void amethod(int iOver){
System.out.println(“Over.amethod”);
}
}

2) public class Rpcraven{
public static void main(String argv[]){
Pmcraven pm1 = new Pmcraven(“One”);
pm1.run();
Pmcraven pm2 = new Pmcraven(“Two”);
pm2.run();
}
}
class Pmcraven extends Thread{
private String sTname=””;
Pmcraven(String s){
sTname = s;
}
public void run(){
for(int i =0; i < 2 ; i++){
try{
sleep(1000);
}catch(InterruptedException e){}
yield();
System.out.println(sTname);}
}
}

3) import java.io.*;
public class Th{
public static void main(String argv[]){
Th t = new Th();
t.amethod();
}
public void amethod(){
try{
ioCall();
}catch(IOException ioe){}
}
}

4) class Background implements Runnable{
int i=0;
public int run(){
while(true){
i++;
System.out.println(“i=”+i);
} //End while
return 1;
}//End run
}//End class

5) class Background implements Runnable{
int i=0;
public int run(){
while(true){
i++;
System.out.println(“i=”+i);
} //End while
return 1;
}//End run
}//End class

6) public class MyFor{
public static void main(String argv[]){
int i;
int j;
outer:
for (i=1;i <3;i++){
inner:
for(j=1; j<3; j++) {
if (j== 2)
continue outer;
System.out.println(“Value for i=” + i + ” Value for j=” +j);
}
}
}

7) class Base
{int i = 99;
public void amethod()
{
System.out.println(“Base.amethod()”);
}
Base(){
amethod();
}
}
public class Derived extends Base
{
int i = -1;
public static void main(String argv[])
{
Base b = new Derived();
System.out.println(b.i);
b.amethod();
}
public void amethod()
{
System.out.println(“Derived.amethod()”);
}
}

8) public class Test{
public static void main(String argv[]){

Test1[] t1 = new Test1[10];
Test1[][] t2 = new Test1[5][];
if (t1[0] == null)
{
t2[0] = new Test1[10];
t2[1] = new Test1[10];
t2[2] = new Test1[10];
t2[3] = new Test1[10];
t2[4] = new Test1[10];
}
System.out.println(t1[0]);
System.out.println(t2[1][0]);

}
}

9) import java.awt.*;
public class Butt extends Frame{
public static void main(String argv[]){
Butt MyBut=new Butt();
}
Butt(){
Button HelloBut=new Button(“Hello”);
Button ByeBut=new Button(“Bye”);
add(HelloBut);
add(ByeBut);
setSize(300,300);
setVisible(true);
}
}

10) class Base {}
class Sub extends Base {}
class Sub2 extends Base {}
public class CEx{
public static void main(String argv[]){
Base b=new Base();
Sub s=(Sub) b;
}
}

11) public class AQuestion
{
public void method()
{
for(int i = 0; i < 3; i++)
{
System.out.print(i);
}
System.out.print(i);
}
}

12) public class AQuestion
{
public static void main(String args[])
{
int a = 5;
System.out.println(“Value is – ” + ((a < 5) ? 9.9 : 9));
}
}

13)
public abstract class AQuestion {
public abstract void prmth1();
public static void prmth2() {
int mth2 = 30;
System.out.println(“prmth2 = ” + mth2);
}
public abstract void prmth3();
}

14) public class AQuestion
{
public static void main(String args[])
{
String river = new String(“Columbia”);
System.out.println(river.length());
}
}

15) public class AQuestion
{
public static void main(String args[])
{
System.out.println(4 | 3);
}
}

16) what is the range of byte?

17) class defination consists of
a) instance variables
b) instance methods
c) constructor
d) none

18) what is the difference b/w int and Integer?
a) Both r primitives
b) int is primivite and Integer is class
c) Integer does not exits
d) None

19) what is Garbage collection in Java?
a) its m/c dependent
b) once the obj references all lost then the memory of it is reclaimed
c) none
d) if none of the files on the system are not used then they r garbage collected

Leave a Reply0

Your email address will not be published.