Tuesday, January 5, 2016

TT TEST -3 In JAVA / III CSE /2016

1.What is the output of the following code?

class Bitwise
{
    public static void main(String [] args)
    {
        int x = 11 & 9;
        int y = x ^ 3;
        System.out.println( y | 12 );
    }
}

2.What is the output of the following code?

public class Test

{

    public int aMethod()

    {

        static int i = 0;

        i++;

        return i;

    }

    public static void main(String args[])

    {

        Test test = new Test();

        test.aMethod();

        int j = test.aMethod();

        System.out.println(j);

    }

 }

3.What is the output of the following code?

int x = l, y = 6;

while (y--)

{

    x++;

}

System.out.println("x = " + x +" y = " + y);

4.What is the output of the following code?

for (int i = 0; i < 4; i += 2)

{

    System.out.print(i + " ");

}

System.out.println(i); /* Line 5 */

5.What is the output of the following code?

int x = 3;

int y = 1;

if (x = y) /* Line 3 */

{

    System.out.println("x =" + x);

}

6.What is the output of the following code?

try

{

    Float f1 = new Float("3.0");

    int x = f1.intValue();

    byte b = f1.byteValue();

    double d = f1.doubleValue();

    System.out.println(x + b + d);

}

catch (NumberFormatException e) /* Line 9 */

{

    System.out.println("bad number"); /* Line 11 */

}

7.What is the output of the following code?

class Super

{

    public int i = 0;

    public Super(String text) /* Line 4 */

    {

        i = 1;

    }

}

class Sub extends Super

{

    public Sub(String text)

    {

        i = 2;

    }

    public static void main(String args[])

    {

        Sub sub = new Sub("Hello");

        System.out.println(sub.i);

    }

}

8.What is the output of the following code?

class Base

{

    Base()

    {

        System.out.print("Base");

    }

}

public class Alpha extends Base

{

    public static void main(String[] args)

    {

        new Alpha(); /* Line 12 */

        new Base(); /* Line 13 */

    }

}

9.What is the output of the following code?

public class X

{

    public static void main(String [] args)

    {

        try

        {

            badMethod();

            System.out.print("A");

        }

        catch (Exception ex)

        {

            System.out.print("B");

        }

        finally

        {

            System.out.print("C");

        }

        System.out.print("D");

    }

    public static void badMethod()

    {

        throw new Error(); /* Line 22 */

    }

}

10.what is the missing code?

public class MyRunnable implements Runnable

{

    public void run()

    {

        // some code here

    }

}

11.What is the output of the following code?

public class While

{

    public void loop()

    {

        int x= 0;

        while ( 1 ) /* Line 6 */

        {

            System.out.print("x plus one is " + (x + 1)); /* Line 8 */

        }

    }

}

12.What is the output of the following code?

public class Test

{

    private static float[] f = new float[2];

    public static void main (String[] args)

    {

        System.out.println("f[0] = " + f[0]);

    }

}

13.What is the output of the following code?

class MyThread extends Thread

{

    public static void main(String [] args)

    {

        MyThread t = new MyThread(); /* Line 5 */

        t.run();  /* Line 6 */

    }

    public void run()

    {

        for(int i=1; i < 3; ++i)

        {

            System.out.print(i + "..");

        }

    }

}

14.What is the output of the following code?

class sam

{

    public static void main(String[] args)

    {

        int i1 = 5;

        int i2 = 6;

        String s1 = "7";

        System.out.println(i1 + i2 + s1); /* Line 8 */

    }

}

15.What is the output of the following code?

public class StringRef

{

    public static void main(String [] args)

    {

        String s1 = "abc";

        String s2 = "def";

        String s3 = s2;   /* Line 7 */

        s2 = "ghi";

        System.out.println(s1 + s2 + s3);

    }

}

          16. Demonstrate Applet.

Saturday, November 14, 2015

Aptitude Q's in C

Q :
1.main()
{
int i=10;
i=!i>14;
printf(“i=%d”,i);
}
try it   results zero
Explanation :
i>14 is 0
!i>14 is 0
reason
!i means !10 is 0
then 0>14 is zero

interpret the stmt like this
i=(!i)>14;   results 0

try it for i=!(i>14); results 1


Wednesday, October 28, 2015

Excel element no to sheet address program in c

#include<stdio.h>
main()
{
 int n,a[20],r,i=0,j;
 clrscr();
 printf("enter element:\n");
 scanf("%d",&n);
 while(n>0)
 {
  r=n%26;
  if(r==0)
  {
   r=26;
   n=n-1;
  }
  a[i]=r;
  i++;
  n=n/26;
 }
 for(j=i-1;j>=0;j--)
  printf("%c",a[j]+64);
 getch();
} 

Arrange Array Elements Using Array Index

# include <stdio.h>
 # include <conio.h>

 /* arrange array */
 main()
 {
  int i[5]={4,3,1,0,2};
  int val[5]={7,9,10,1,8};
  int j,pos,tmp,tmp_pos;
  int x,y;

  for(x=0;x<=3;x++)
  {
  for(y=x+1;y<=4;y++)
  {
   if(i[x]>i[y])
   {
    tmp=val[x];
    val[x]=val[y];
    val[y]=tmp;
    tmp=i[x];
    i[x]=i[y];
    i[y]=tmp;
   }
  }
  }

  clrscr();


  for(j=0;j<=4;j++)
  printf("%3d,",val[j]);


}

Saturday, May 2, 2015

TT TEST-II Java Programming For #rd Yr

Technical Test - 2


1.What modifiers are allowed for methods in an Interface?
a)abstract, public    b)abstract,private    c)none  
2 .Can there be an abstract class with no abstract methods in it? 
   a)yes    b)no
3. Can we instantiate an abstract class?
     a)yes    b)no
4. Is it possible to override the main method?
a)yes    b)no
       5. Can we create an object for an interface?
a)yes    b)no
       6. Is null a keyword?
a)yes    b)no
       7. out object is member of which class ?
            a)PrintStream    b)System   c)OutStream     d)InStream
       8.next() is a member of which class?
            a)BufferReader    b)DataInputStream   c)Scanner    4)none
       9. How we can access library classes members ________________
     10. class x
             {          public dis() { System.out.println(“RISE@GSK”); }
                         Public static void main(String[]args){
                        new  x().dis();}
             }
            Guess the output
            a)compile time error   b)run time error    c)RISE@GSK    d)none

     11. class MyClass
             {         
                         public  void  main(String[]args){
System.out.println(“RISE@GSK”);
                        }
             }

            a)compile time error   b)run time error    c)RISE@GSK    d)none

     12.      
What is the value of "d" after this line of code has been executed?
double d = Math.round ( 2.5 + Math.random() );
                 a)2      b)3     c)4     d)2.5
13.What is the prototype of the default constructor?
Test( )
Test(void)
public Test( )
public Test(void)
14. You want subclasses in any package to have access to members of a superclass. Which is the most restrictive access that accomplishes this objective?
public
private
protected
transient

15.Which will legally declare, construct, and initialize an array?
A.int [] myList = {"1", "2", "3"}; B. int [] myList = (5, 8, 2); C. int myList [] [] = {4,9,7,0};
D. int myList[] = {4, 3, 7};


Tuesday, April 28, 2015

TECHNICAL TEST2

TECHNICAL TEST2     by RVS
-----------------------------------------------------------------------------------------------------
1.#include<stdio.h>
int main(){
    int i,j;
    i=j=(2,3),0;
    while(--i&&j++)
         printf(" %d %d",i,j);
    return 0;
}
a)1 3     b)none  c)13  02  d)24 25

2. int main()
{
            int i=1,n;
            clrscr();
            for(i=0,n=0;i<=5;n+=i++);
            printf("%d",n,n=9);
}

a)25      b)21      c)9        d)15

3.int main()
{
char c=’a’;
do
printf("%d ",c);
while(c--);
return 0;
}
a) finate loop prints 65,64,63….0  
b)infinite loop c)compilation error d) finite loop prints 65,66,67……

4. #include<stdio.h>
int main()
{
                int i=10;
                int no[2][4]={1,0,2};
                printf("%d",sizeof(no));

}
a)6          b)8         c)2          d)16

6. main(){
 char*str=”I love java”;
str=str+3;
printf(“%s”,str);
}
a.i love java        b)error   c)ove java    d)ve java
 7.
void main()
{
char *s="\123\n";
printf("%d",sizeof(s));
}
a)4   b)2    c)6     d)error
8. main()
{
  char *str="ECETT";
clrscr();

printf("%s   %s   %c  ",str+1,str,*str++);
}
a)ETT CETT E   b)ECE TT T  c)error    d)CET CETT C

9. main()
{
  char a[]="%d\n";
  clrscr();
a[1]='c';
printf(a,68);
getch();
}
a)error    b)D     c)c      d)D with new line
10.
main()
{
            printf(“%d”,10?0?5:1:12)
}
a) 1      b)12      c)12      d)0

11. void main()
{
int a=3;
clrscr();
if(a==1);
a=2<<1;
printf("%d",a,a=~a);
}

     a.   4
     b.     nothing
     c.     -5
     d.     1

12. main(){
 char*s={”I love java”};
printf(“%c”,s[0]);
}
a)error   b)i love java   c)I     d)null

13. #include<stdio.h>
main()
{
  char not=!EOF;
  clrscr();
  printf("\n%d %d",EOF,not);
}
a. 0 0    b.error  c.-1 0   d.-1 1

14.
 # include <stdio.h>
main()
{
 char not='\0';
int i;
i=not==NULL;
clrscr();
printf("%d",i);
}
a.48                  b.compile time error
c.0                    d.1


15.What will be output of following c code?
        
#include<stdio.h>
int main(){
    int i=3,j=2;
    clrscr();
    while(i--?--j:j++)
             printf("%d",j);
    return 0;
}

a.-1      b)0 1     c)0        d)1


16 (5 marks)

Print the following using loops

54321012345









Monday, April 27, 2015

TEST - 3: C-PROGRAMMING:



GRAND  TEST : C-PROGRAMMING:
1#include<stdio.h>
void main()
{
            clrscr();
            if(printf("0"))
            printf("true");
            else
            printf("false");
}
a)true  b)0true            c)false d)0
----------------------------------------------------------
2.#include<stdio.h>
void main()
{
            char ch='A0';
            clrscr();
            
            printf("%d",ch);

}
a)0    b)a          c)65     d)error
----------------------------------------------------------
3.#include<stdio.h>
void main()
{
            int ch=NULL || EOF+1 && EOF ;
            clrscr();
            printf("%d",ch);
}
a)0       b)1       c)-1      d)48
----------------------------------------------------------
4.#include<stdio.h>
void main()
{                       printf("a\/b=c");
}
a)a=c   b)a\/b=c          c)a/b=c                        d)error
----------------------------------------------------------
5.#include<stdio.h>
void main()
{           clrscr();
printf("%d",1||printf("ok"));
}
a)1       b)1ok   c)error d)ok1
6.#include<stdio.h>
void main()
{
            float x=10.2345F;
            int a;
            clrscr();
            a=x-(int)x;
            printf("\n%f",(float)a);
}
a)10.234500                b)0.000000                  c)error                         d)10.2345
7.#include<stdio.h>
void main()
{
            clrscr();
            printf("a%cb",'\\b');
}
a)a\b               b)a\\b              c)b       d)error
8.#include<stdio.h>
void main()
{
            float f=2.0;
            clrscr();
            printf("%d",sizeof(f));

}
a)4       b)8       c)6       d)error

----------------------------------------------------------
9. #include<stdio.h>
void main()
{
            char ch='ab';
clrscr();
            do
            {
                        printf("%c",ch++);
            }while(ch!='c'+1);}
a)abc   b)ab     b)abcd             d)error
10. #include<stdio.h>
void main()
{
            enum color{red,green=3,blue};
clrscr();
            printf(“\n %d”,red+green);
}
a)5       b)3       c)0       d)none
11. #include<stdio.h>
void main()
{char ch='0a';
                switch(ch)
                {
                case '0a':
                                puts("\nfirst");  break;
                                case 48:
                                puts("\nsecond");break;
                                default:                printf("wrong");
                }
}
a)first  b)wrong     c)error      d)second
12. #include<stdio.h>
void main()
{
            int a=5^8;
            printf("%d",a*a);
}
a)13     b)169   c)-169  d)-13
13.        #include <stdio.h>
        int main()
        {            int i = 0, j = 0;
            while (i < 5, j < 10)
            {
                i++;        j++;
            }
            printf("%d, %d\n", i, j);
        }
a)0,0    b)5,5    c)10,10    d)error
14. #include <stdio.h>
        int main()
            {           int a=7,b=2;
printf("\n%d",(int)((float)a/b-(int)a/b));
        }
a)0.5    b)0       c)0.500000      d)error
15. #include <stdio.h>
        int main()
            {
            int i=10,j=9;
            clrscr();
                        while(--i && j++);
                        printf("\n%d %d",i,j);
        }
a)1   19            b)0   18           c)1  10 d)1  19

16.write a program to print .  print   (6  marks )
            0
            1 0
            0 1 0
            1 0 1 0
            0 1 0 1 0