Google Analytics

Friday, 19 August 2011

FRP UNIX PAPER 2 SAMPLE QUESTION WITH ANSWERS


Sample Paper-2
1)The “kill -9 <PID>” command sends which of the following signals to the process?
a)INT
b)TERM
c)KILL
d)STOP

Answer: C.

2)If the STAT column of the output of the ps command shows that the process state of a given process is ‘S’, then which of the following is not true:
a)The process has been stopped or suspended from execution
b)The process is waiting for a resource
c)The kernel scheduler has pre-empted the process from execution because it has finished its allotted time slice
d)a & b

Answer: B.
Description: The process state of a suspended process is T;Process waiting for a resource moves to sleep state S;process pre-empted from kernel because it has run its time slice waits in the run queue, state is R

3)When a child process exits before the parent process exits, which of the following is true:
a)the child process becomes defunct
b)the process state for the parent process is shown as Z
c)if the parent process does not handle SIGCHLD, the child process becomes a zombie
d)none of the above

Answer: A.

4)A user does the following from the command line::
$ a.out &
[1] 8112
$ sh
$ a.out &
[1] 8216
$ ps
PID     TTY                 TIME              CMD
8001    tty1                  00:00:00          csh
8112    tty1                  00:00:00          a.out
8215    tty1                  00:00:00          sh
8216    tty1                  00:00:00          a.out
If the user executes the command “kill -9 8215”, then which of the following is true?

a)The a.out instance ( PID = 8216 ) is also terminated
b)a.out(PID=8216) becomes a defunct process
c)a.out(PID=8112) becomes a zombie, with parent as 8001
d)a.out(PID=8216) has parent process as 1

Answer: D.
 sh ( PID=8215) is the parent of a.out (PID=8216). Hence when sh is killed, init(PID=1) becomes parent of a.out (PID=8216)

5)which of these is NOT a valid variable in bash
a)__       (double underscore)
b)_1var    (underscore 1 var )
c)_var_    (underscore var underscore)
d)some-var (some hyphen var)

Answer:D.
Description: Hyphen's cant be used in variable name. It is encouraged to use meaningful variables instead of __ etc,though.  well, hyphen means subtract in appropriate context.

6)Assuming bash shell, what is the output of the following command:  
echo hello $0
a)hello echo
b)hello hello
c)hello bash
d)hello

Answer:C.
Description:"hello bash". The command is internally run in a forked bash & that bash itself is the zeroth argument.
Note, echo is just builtin command to shell Note. 

7)Assuming bash shell, what is the oputput of team=Unix  
echo 1.$team   2."$team"   3.'$team'   4.\$team
a)1.Unix   2.Unix   3.Unix    4.Unix
b)1.Unix   2.Unix   3.$team   4.$team
c)1.Unix   2.Unix   3.Unix    4.$team
d)1.Unix   2.$team   3.$team   4.$team

Answer: B.

8)Assuming bash shell, what is the return value ($?) after running this script :
team=Unix
[ $teamFCG = UnixFCG ] &&  exit 2
[ ${team}FCG = UnixFCG ] &&  exit 3
a)0
b)1
c)2
d)3 

Answer: D.
Description: $teamFCG does not evaluate since variable $teamFCG doesnt exits. since the first expression was FALSE, it does not execute the exit 2 (after &&).  ${team}FCG evaluates to UnixFCG, hence the script exits with 3 

9)which of these is/are the correct method for writing "foo" in /tmp/bar file?
1. echo foo > /tmp/bar
2. echo foo >> /tmp/bar
3. echo foo | /tmp/var
4. /tmp/bar < echo foo


a)1 & 2. 
b)all four amount to the same
c)1 and 3
d)3 and 4

Answer: A.
Description:  echo foo > /tmp/bar or echo foo >> /tmp/bar are correct

10)To have the errors from the output of a command displayed, which is the correct syntax?
a)command  3> &2
b)command  2> &1
c)command  2> 1&
d)command  2> /dev/null

Answer: B.

C Programs during trng


  1.  /*  Program 7 - ANYFILE.C */
#include <stdio.h>
#include <stdlib.h>


int main()
{
FILE *fp1;
char oneword[100], filename[25];
char *c;


   printf("Enter filename -> ");
   scanf("%s", filename);            /* read the desired filename  */
   fp1 = fopen(filename, "r");
   if (fp1 == NULL)
   {
      printf("File failed to open\n");
      exit (EXIT_FAILURE);
   }


   do 
   {
      c = fgets(oneword, 100, fp1);  /* get one line from the file */
      if (c != NULL)                
         printf("%s", oneword);      /* display it on the monitor  */
   } while (c != NULL);              /* repeat until NULL          */


   fclose(fp1);


   return EXIT_SUCCESS;
}




/* Result of execution


(The file selected is listed on the monitor)


*/







                             /*   Program 6 - BACKWARD.C */
#include <stdio.h>       /* Prototypes for standard Input/Output   */
#include <string.h>      /* Prototypes for string operations       */


void forward_and_backwards(char line_of_char[], int index);


int main()
{
char line_of_char[80];
int index = 0;


   strcpy(line_of_char, "This is a string.\n");


   forward_and_backwards(line_of_char, index);


   return 0;
}



void forward_and_backwards(char line_of_char[], int index)
{
   if (line_of_char[index]) 
   {
      printf("%c", line_of_char[index]);
      index++;
      forward_and_backwards(line_of_char, index);
   }
   printf("%c", line_of_char[index]);
}





/* Result of execution


This is a string.


.gnirts a si sih


*/

 /* Pointer*/



#include <stdio.h>
#include <string.h>


int main()
{
char strg[40], *there, one, two;
int  *pt, list[100], index;


   strcpy(strg, "This is a character string.");


   one = strg[0];                    /* one and two are identical */
   two = *strg;
   printf("The first output is %c %c\n", one, two);


   one = strg[8];                   /* one and two are indentical */
   two = *(strg+8);
   printf("The second output is %c %c\n", one, two);


   there = strg+10;          /* strg+10 is identical to &strg[10] */
   printf("The third output is %c\n", strg[10]);
   printf("The fourth output is %c\n", *there);


   for (index = 0 ; index < 100 ; index++)
      list[index] = index + 100;
   pt = list + 27;
   printf("The fifth output is %d\n", list[27]);
   printf("The sixth output is %d\n", *pt);


   return 0;
}




/* Result of execution


The first output is T T
The second output is a a
The third output is c
The fourth output is c
The fifth output is 127
The sixth output is 127


*/

Sample PRP Questions


1.   compile and/or run the program?
      package mypack;
      public class A {
       public void m1() {System.out.print("A.m1");}
      }  
      class B {
       public static void main(String[] args) {
         A a = new A(); // line 1
         a.m1();  // line 2
      }}

    prints: A.m1
    Compile-time error at line 1
    Compile-time error at line 2
    Run-time error at line 1

2.
      class Super{
      int i=0;
      Super(String s){
      i=10;
      }
      }
      class Sub extends Super {
      Sub(String s){
      i=20;
      }
      public static void main(String args[]) {
      Sub b=new Sub("hello");
      System.out.println(b.i);
      }
      }      
      What is the output ?

    Compilation Error
    Runtime Error
    10
    20

3.
Which of the following is not a mandatory attribute for <APPLET> tag?

    code
    width
    height
    name

4.
________ components can be used for guiding the user with description for input components  in GUI.

    JLabel
    JPanel
    JButton
    Any of the above

5.

What is the result of attempting to compile and run the program
      // Class A is declared in a file named A.java.
      package pack1;
      public class A {
       void m1() {System.out.print("A.m1");}  
      }
      // Class D is declared in a file named D.java.
      package pack1.pack2;
      import pack1.A;
      public class D extends A{
       public static void main(String[] args) {
         A a = new A(); // line 1
         a.m1();  // line 2
         }}

    Prints: A.m1
    Compile-time error at  line1.
    Compile-time error at line 2.
    Run-time error at  line 1.

6.

What is the result of attempting to compile and run the program
      // Class A is declared in a file named A.java.
      package pack1;
      public class A {
      protected void m1() {System.out.print("A.m1");}  
      }
      // Class D is declared in a file named D.java.
      package pack1.pack2;
      import pack1.A;
      public class D extends A{
       public static void main(String[] args) {
         A a = new A(); // line 1
         a.m1();  // line 2
         }}

    Prints: A.m1
    Compile-time error at  line1.
    Compile-time error at line 2.
    Run-time error at  line 1.


7.

What gets printed when the following gets compiled and run:
      public class example {
      public static void main(String args[]) {
      int x = 0;
      if(x > 0) x = 1;
      switch(x) {
      case 1: System.out.print(“1”);
      case 0: System.out.print(“0”);
      case 2: System.out.print(“2”);
      break;
      }
      }
      }

    0
    102
    1
    02

8.
A software blueprint for objects is called a/an

    Interface
    Class
    Prototype
    method

9.
What is the output when the following code is compiled and/or executed?
      public class Test {
      private void method(){
      System.out.println(“method”);
      throw new RuntimeException();
      }
      public static void main(String[] args){
      Test t = new Test();
      t.method();
      }
      }

 Compile time error
 Throws RuntimeException
 Throws IllegalAccessException
 No output

10.

Which of the following layout manager arranges components along  north, south, 
east, west and center of the  container?

 BorderLayout
 BoxLayout
 FlowLayout
 GridLayout

11.

What is the result of attempting to compile and run the program:
      // Class A is declared in a file named A.java.
      package pack1;
      public class A {
       public void m1() {System.out.print("A.m1");}

      }
      // Class D is declared in a file named D.java.
      package pack1.pack2;
      import pack1.A;
      public class D {
       public static void main(String[] args) {
         A a = new A(); // line 1
         a.m1();  // line 2  
      }}

 Prints: A.m1
 Compile-time error at  line1.
 Compile-time error at line 2.
 Run-time error at  line 1.

12.
Which of the following is not a primitive data type

 int
 bool
 float
 long

13.

Which of the following keyword can be used for intentionally throwing user
defined exceptions?

 throw
 throws
 finally
 try

14.

Class A{
A(){}
}

Class B{}

Class C
{
            Public static void main(String arg[])
{
}
}

  1. Compile and run
  2. will not compile
  3. will throw runtime exception

15.

Class A{
A(){}
}

Class B
{
            B(int x){}
}

Class C
{
            Public static void main(String arg[])
{
            A ab=new A();
            B cd=new B();
}
}

  1. Compile and run
  2. will not compile
  3. will throw runtime exception

16.

Class A{
A(){}
}

Class B
{
            B(){}
            B(int a){super(200);}
}

Class C
{
            Public static void main(String arg[])
{
A ab=new A();
            B cd=new B(23);

}
}

  1. Compile and run
  2. will not compile
  3. will throw runtime exception


17.

Consider the following prg
Class A
{
Psvm(String a[])
{

        int x[]={1,2,3};
        try
{
For(int i=0;i<x.length();i++)
{
S.op(x[i]);
}
S.o.p(“Done”);
}
Catch(NullPointerException ne)
{
S.o.p(“Catch”);
}
Finally
{
S.o.p(“Final”);
}
S.o.p(“XXX”);
}
}

  1. Compile time err
  2. Run time errjm
  3. Prints:123donefinalxxx
  4. Prints123catchdonefinalxxx

18.

Consider the following prg
Class A
{
Psvm(String a[])
{

        int x[]={1,2,3};
        try
{
For(int i=0;i<=x.length();i++)
{
S.op(x[i]);
}
S.o.p(“Done”);
}
Catch(ArrayIndexOutofBoundException ae)
{
S.o.p(“Catch”);
}
Finally
{
S.o.p(“Final”);
}
S.o.p(“XXX”);
}
}

  1. Compile time err
  2. Run time err
  3. Prints:123catchfinal
  4. Prints123catchdonefinalxxx

19.

Protected memebr are visible in

  1. Inside same class
  2. inside same package
  3. inside same package and subclases of other package

20.

--------- keyword is used to declare class as abstract

  1. public
  2. private
  3. abstract

21.
Which of the following can not be declared inside <Head>
  1. table
  2. script
  3. style
  4. title

22.
In <img> tag src is used for ---------
  1. type of image
  2. path of file
  3. type of file

23.
Wrapper class for char is -------
  1. CHAR
  2. character
  3. Char
  4. Character

24.
In ordered list default attribute for type is\
  1. 1
  2. A
  3. I
  4. i

25.

In which list tag list will be printed as 1. 2. 3. 4. …….
  1. <ul>
  2. <ol>
  3. <dt>
  4. <dl>

26.
Which of the following attribute for giving line break in html
  1. <BR>
  2. line break
  3. line_break

27.
Which of the following attribute is invalid in <Form>
  1. name
  2. action
  3. method
  4. Get

28.
Which of the following can be used to create filled form
  1. <form>
don’t remember other options……

29.
What is the coorect way to declare script language
  1. <script language=”XXX.js”>
  2. language=java script
  3. <script_language=”java script”>
  4. <script language=”java script”>

30.
Which of the following can be used to itterate through all the objects

  1. do … while
  2. while
  3. for in
  4. for

31.
which of following is correct way to declare arrays in java script

  1. a={1,2,3}
  2. a=new {1,2,3}
  3. a=new Array(10);

32.
“Network is a computer” is themeline of _________
  1. microsoft
  2. Cisco
  3. Sun microsystem
  4. IBM
  5. Wipro Technologies

33.
setTimeOut() method in java script is used to

  1. delay the java script by specified time
  2. block the browser for specified time
  3. display time
  4. set the clock

34.
<Title> tag is declared in side which tag

  1. Before <Body>
  2. After <Body>
  3. Between <Head>
  4. Anywhere in html

35.
Which is not a font attribute

  1. size
  2. color
  3. face
  4. list

36.

Which of the following is used to display > symbol in html
  1. &th;
  2. &gt;
  3. &#174
  4. &#169

37.what is default value for method attribute in <Form>

  1. get
  2. post
  3. set
  4. let

38.
How we call function abc() in java script.
  1. call abc()
  2. calling abc
  3. abc()
  4. none

39.
which method is used to get the values of components in html
  1. getParam()
  2. getParameter()
  3. getValue()
  4. getParameterValues()

40.
All classes extends Object true or false
  1. true
  2. false

41.       In Java which event handling method called when page finish to load 
•           onFinish
•           onLoad
•           onCompile
•           onImage

42.
.           What is the maximum size of an cookie
•           4kb
•           20kb
•           300kb
•           30kb

43. how many cookies per web server browser supports.
1. 10
2. 22
3. 30
4. 20

44.
How to create new window in java script

  1. a=new window();
  2. window.open(“ABC”);
  3. mywin=open(“ABC”,”disp”)

45.
What we use for session tracking if there is no cookie.
  1. url rewriting
  2. session object
  3. not possible without cookies

46.
In jdbc type 4 driver is written in

  1. java
  2. native
  3. c
  4. c++

47.
What is the correct format of JDBC URL
  1. jdbc:<subprotocol>:<subname>
  2. jdbc:<subprotocol>:<subname>:driver
  3. jdbc:<subprotocol>

48

From which class / interface statement can be created
  1. Statement
  2. Connection
  3. Class
  4. Resultset

49.
When no data is found which of the following will return false

  1. % rowcount
  2. %found
  3. %notfound

50.
What is used to set attributes in callable statement

  1. *
  2. $
  3. #
  4. ?



51.
JSP means

  1. java server pages
  2. java super pages
  3. java supported pages

52.
Diff between include directive and <jsp:include>

53.
One question on getServletConfig.getInitParameter()

54.
What is compulsary in in <jsp:usebean>
  1. name
  2. calss
  3. type
  4. id

55.
Which of the following is mutating
  1. setValue()
  2. setProperty()
  3. getProperty()
  4. getValue()

56.
Jsp pages are compiled into

  1. java server pages
  2. servlet
  3. classes
  4. bytecode


57. questions on commit and rollback in case of trigger

58. question related to user_tables

59. question related to creating procedure and then again compiling it then what will be its status in data dictionary

  1. valid
  2. invalid
  3. compiled

60. pure functions in case of oracle.

61. java support multiple inheritance using classes T/F

62. foreign key can be created on more than on coloumn T/F

63. Question regarding Check Constraint.

64. def of trigger

65. if u want to return value wt will u use
1. procedure
2. function
3. anonymous block.

66.
 Number of methods available in MouseListener Interface
            a)1
            b) 5
            c) 6
            d) 4

67.

Which is not a jsp:setproperty?
            a) name
            b) property
            c) Id
            d) Param
68.

Java Applets can be executed in _______________

            a) Java-enabled web browser
            b) windows web browser
            c) any web browser
            d) none of the above

69. inline queries can be written in select using

  1. select
  2. from
  3. in