Tuesday, October 29, 2013

Programming (C, C++ ...) 02

11. Assume that we have constructor functions for both base class and derived class. Now consider the declaration in main( ). Base * P = new Derived; in what sequence will the constructor be called? [Paper III June 2012]
(A) Derived class constructor followed by Base class constructor.
(B) Base class constructor followed by derived class constructor.
(C) Base class constructor will not be called.
(D) Derived class constructor will not be called.

12. printf(“%c”, 100); [Paper II June 2012]
(A) prints 100
(B) prints ASCII equivalent of 100
(C) prints garbage
(D) none of the above

13. Which API is used to draw a circle ? [Paper II December 2012]
(A) Circle( )                 (B) Ellipse( )
(C) RoundRect( )         (D) Pie( )

14. Which of the following are two special functions that are meant for handling exception, that occur during exception handling itself? [Paper II December 2012]
(A) void terminate ( ) and void unexpected ( )
(B) Non void terminate ( ) and void unexpected ( )
(C) void terminate ( ) and non void unexpected ( )
(D) Non void terminate ( ) and non void unexpected ( )

15. Match the following with respect to C++ data types: [Paper II December 2012]
a. User defined type 1. Qualifier
b. Built in type 2. Union
c. Derived type 3. Void
d. Long double 4. Pointer
Code :
       a b c d
(A) 2 3 4 1
(B) 3 1 4 2
(C) 4 1 2 3
(D) 3 4 1 2

16. Enumeration is a process of [Paper II December 2012]
(A) Declaring a set of numbers
(B) Sorting a list of strings
(C) Assigning a legal values possible for a variable
(D) Sequencing a list of operators

17. Which of the following mode declaration is used in C++ to open a file for input?
[Paper II December 2012]
(A) ios : : app
(B) in : : ios
(C) ios : : file
(D) ios : : in

18. What is the result of the following expression? [Paper II December 2012]
(1 & 2) + (3 & 4)
(A) 1
(B) 3
(C) 2
(D) 0


SOLUTIONS

11. B
Here A derived class object is created first and then assigned to a base class pointer. Whenever a derived class object is created, the base class constructor gets called first and then the derived class constructor.

12. B

13. B

14. A
The visual C++ Standard requires that unexpected() is called when a function throws an exception that is not on its throw list.
The terminate( ) function is used with visual C++ exception handling and is called in the following cases:

  • A matching catch handler cannot be found for a thrown C++ exception.
  • An exception is thrown by a destructor function during stack unwind.
  • The stack is corrupted after throwing an exception.

Both the functions does not return anything.

15. A

16. C
An enum is a user-defined type consisting of a set of named constants called enumerators. The colors of the rainbow would be mapped like this.:
              enum rainbowcolors { red,  orange, yellow, green,  blue, indigo, violet)  }
Now internally, the compiler will use an int to hold these and if no values are supplied, red will be 0, orange is 1 etc.

17. D
In order to open a file with a stream object we use its member function open():
          open (filename, mode);
Where filename is a null-terminated character sequence of type const char * (the same type that string literals have) representing the name of the file to be opened, and mode is an optional parameter with a combination of the following flags:

  • ios::in    Open for input operations.
  • ios::out    Open for output operations.
  • ios::binary  Open in binary mode.
  • ios::ate    Set the initial position at the end of the file. If this flag is not set to any value, the initial position is the beginning of the file.
  • ios::app    All output operations are performed at the end of the file, appending the content to the current content of the file. This flag can only be used in streams open for output-only operations.
  • ios::trunc    If the file opened for output operations already existed before, its previous content is deleted and replaced by the new one.

18. D
& represents bitwise AND. Converting the given values in the expression to 4 bit binary we have:
(1 & 2) + (3 & 4) = (0001 & 0010) + (0011 & 0100)
                            = (0000) + (0000)
                            = 0 + 0
                            = 0

Sunday, August 18, 2013

Operating Systems 03

21. Resources are allocated to the process on non-shareable basis is
[Paper II June 2012]
(A) mutual exclusion
(B) hold and wait
(C) no pre-emption
(D) circular wait

22. Cached and interleaved memories are ways of speeding up memory access between CPU’s and slower RAM. Which memory models are best suited (i.e. improves the performance most) for which programs?     [Paper II June 2012]
(i) Cached memory is best suited for small loops.
(ii) Interleaved memory is best suited for small loops
(iii) Interleaved memory is best suited for large sequential code.
(iv) Cached memory is best suited for large sequential code.
(A) (i) and (ii) are true.
(B) (i) and (iii) are true.
(C) (iv) and (ii) are true.
(D) (iv) and (iii) are true.

23. Consider the following page trace: 4,3, 2, 1, 4, 3, 5, 4, 3, 2, 1, 5
Percentage of page fault that would occur if FIFO page replacement algorithm is used with number of frames for the JOB m = 4 will be                       [Paper II June 2012]
(A) 8                (B) 9
(C) 10             (D) 12


24. Given memory partitions of 100 K, 500 K, 200 K, 300 K and 600 K (in order) and processes of 212 K, 417 K, 112 K, and 426 K (in order), using the first-fit algorithm, in which partition would the process requiring 426 K be placed ?                  [Paper II December 2012]
(A) 500 K
(B) 200 K
(C) 300 K
(D) 600 K

25. The problem of indefinite blockage of low-priority jobs in general priority scheduling algorithm can be solved using:   [Paper II December 2012]
(A) Parity bit
(B) Aging
(C) Compaction
(D) Timer

26. Which of the following memory allocation scheme suffers from external fragmentation?
[Paper II December 2012]
(A) Segmentation
(B) Pure demand paging
(C) Swapping
(D) Paging

27. In UNIX, which of the following command is used to set the task priority?      
[Paper II December 2012]
(A) init
(B) nice
(C) kill
(D) PS




SOLUTIONS
21. A

22.

23. C
The first 4 page references will cause page faults and they are brought into the 4 page frames available. The sequence is shown below
4 - page fault, brought to frame. Page Frame : 4
3 - page fault, brought to frame. Page Frame : 4, 3
2 - page fault, brought to frame. Page Frame : 4, 3, 2
1 - page fault, brought to frame. Page Frame : 4, 3, 2, 1
4 - available in the frame, no page fault occurs. Page Frame : 4, 3, 2, 1
3 - available in the page frame, no page fault occurs. Page Frame : 4, 3, 2, 1
When the fame is full and a page fault occurs, then the page that was first brought in is removed and the referred page is brought in to the frame.
5 - not in the page frame, page fault. 4 is removed and 5 is brought is. Page Frame : 5, 3, 2, 1
4 - not in the page frame, page fault. 3 is removed and 4 is brought is. Page Frame : 5, 4, 2, 1
3 - not in the page frame, page fault. 2 is removed and 3 is brought is. Page Frame : 5, 4, 3, 1
2 - not in the page frame, page fault. 1 is removed and 2 is brought is. Page Frame : 5, 4, 3, 2
1 - not in the page frame, page fault. 5 is removed and 1 is brought is. Page Frame : 1, 4, 3, 2
5 - not in the page frame, page fault. 4 is removed and 5 is brought is. Page Frame : 1, 5, 3, 2

24. A
100 K, 500 K, 200 K, 300 K and 600 K (in order) and processes of 212 K, 417 K, 112 K, and 426 K
According the to the first fit algorithm, the memmory will be scanned to find out the memory portion that is enough for the arriving process, The first such portion found is allocated to the process. In the given example when process of size 212K arrives it is placed in memory portion with size 500K. This leaves an unused space of 288K. Now 417K arrioves it is placed inportion with size 600K, leaving 183K unused. Now 112K arrives and this can be placed in the un used sopace of 183K. Atlast the process of 426K arrives, we dont have memory block large enough to hold this, so we need to remove some already allocated process and allocate that block. 500k block is the one suitable if we do a linear search.
25. B

26. A

27. B
init - Init is the parent of all processes. Its primary role is to create processes from a script stored in the file
nice - run a program with modified scheduling priority
kill - terminate a process

ps - report process status

Wednesday, August 7, 2013

Web 01

01. Match the following with respect to HTML tags and usage          [Paper III December 2012]
a. CITE                       1.Italic representation
b. EM                          2.Represents output from programmes
c. VAR                        3.Represents to other source
d. SAMP                     4.Argument to a programme
Codes :
A         b          c          d
(A)       3          1          4          2
(B)       2          3          1          4
(C)       4          2          3          1
(D)       1          3          4          1

02. Which one is a collection of templates and rules?     [Paper III December 2012]
(A) XML
(B) CSS
(C) DHTML
(D) XSL

03. Which is the method used to retrieve the current state of a check box?
[Paper III December 2012]
(A) get State ( )
(B) put State ( )
(C) retrieve State ( )
(D) write State ( )

04. BCC in the internet refers to             [Paper II December 2011]
(A) Black carbon copy
(B) Blind carbon copy
(C) Blank carbon copy
(D) Beautiful carbon copy

05. Data security threats include           [Paper II December 2011]
(A) privacy invasion
(B) hardware failure
(C) fraudulent manipulation of data
(D) encryption and decryption

06. HTML is defined using SGML – an _______ standard, information processing-text and office systems (SGML) for text information processing.           [Paper III June 2012]
(A) ISO – 8878
(B) ISO – 8879
(C) ISO – 8880

(D) ISO – 8881


SOLUTIONS

1. A
The <cite> tag defines the title of a work (e.g. a book, a song, a movie, a TV show, a painting, etc.).
The <em> tag is a phrase tag. It renders as emphasized text.
The <var> tag is a phrase tag. It defines a variable.
The HTML <samp> tag is used for indicating sample output from a computer program, script etc.

2. D
Extensible Markup Language (XML) is a markup language that defines a set of rules for encoding documents in a format that is both human-readable and machine-readable.
Cascading Style Sheets (CSS) is a style sheet language used for describing the presentation semantics (the look and formatting) of a document written in a markup language.
Dynamic HTML, or DHTML, is an umbrella term for a collection of technologies used together to create interactive and animated web sites by using a combination of a static markup language (such as HTML), a client-side scripting language (such as JavaScript), a presentation definition language (such as CSS), and the Document Object Model.
Extensible Stylesheet Language (XSL) is used to refer to a family of languages used to transform and render XML documents. XSL consists of three parts:
  • XSLT - a language for transforming XML documents
  • XPath - a language for navigating in XML documents
  • XSL-FO - a language for formatting XML documents


3. A

4. B

5.

6. B
ISO – 8878: Telecommunications and information exchange between systems. Use of X.25 to provide the OSI connection-mode network service.
ISO – 8879: Information processing -- Text and office systems -- Standard Generalized Markup Language (SGML)
ISO – 8880: Information technology -- Telecommunications and information exchange between systems -- Protocol combinations to provide and support the OSI Network Service
ISO – 8881: Information processing systems -- Data communications -- Use of the X.25 packet level protocol in local area networks

Saturday, August 3, 2013

Programming (C, C++ ...) 01

01. When a programming Language has the capacity to produce new datatype, it is called as,
[Paper III December 2012]
(A) Overloaded Language
(B) Extensible Language
(C) Encapsulated Language
(D) Abstraction Language                  

02. The Default Parameter Passing Mechanism is called as       [Paper III December 2012]
(A) Call by Value
(B) Call by Reference
(C) Call by Address
(D) Call by Name

03. Functions defined with class name are called as                   [Paper III December 2012]
(A) Inline function            (B) Friend function
(C) Constructor               (D) Static function

04. Assume that we have constructor functions for both base class and derived class. Now consider the declaration in main( ). Base * P = New Derived; in what sequence will the constructor be called? 
[Paper III June 2012]
(A) Derived class constructor followed by Base class constructor.
(B) Base class constructor followed by derived class constructor.
(C) Base class constructor will not be called.
(D) Derived class constructor will not be called. 

05. Consider the program below in a hypothetical programming language which allows global variables and a choice of static or dynamic scoping                  [Paper III December 2012]
int i;
program Main( )
{
       i = 10;
       call f ( );
}
procedure f( )
{
        int i = 20;
        call g ( );
}
procedure g( )
{
       print i;
}
Let x be the value printed under static scoping and y be the value printed under dynamic scoping. Then x and y are
(A) x = 10, y = 20
(B) x = 20, y = 10
(C) x = 20, y = 20
(D) x = 10, y = 10

06. printf(“%c”, 100);                                  [Paper II June 2012]
(A) prints 100
(B) prints ASCII equivalent of 100
(C) prints garbage
(D) none of the above

07. X – = Y + 1 means                               [Paper III December 2012]
(A) X = X – Y + 1
(B) X = –X – Y – 1
(C) X = –X + Y + 1
(D) X = X – Y – 1

08. The _______ memory allocation function modifies the previous allocated space. 
[Paper III June 2012]
(A) calloc( )                 (B) free( )
(C) malloc( )                (D) realloc( )

09. The mechanism that binds code and data together and keeps them secure from outside world is known as                  .           [Paper III June 2012]
(A) Abstraction           (B) Inheritance
(C) Encapsulation       (D) Polymorphism

10. Match the following with respect to java.util.* class methods:     [Paper III June 2012]
(a) Bit Set                    (i) Time zone getTimezone( )
(b) Calendar                (ii) int hashcode( )
(c) Time zone              (iii) int nextInt( )
(d) Random                 (iv) void setID(String tzName)
(a)        (b)        (c)        (d)
(A)       (ii)        (i)         (iv)       (iii)
(B)       (iii)       (iv)        (i)         (ii)
(C)       (iv)       (iii)        (ii)        (i)
(D)       (ii)        (i)         (iii)       (iv)



SOLUTIONS
1. B

2. A

3. C

4.

5. D
Whatever be the scoping, the i declared inside the method f() is not accessible outside. So when we say i from g(), it refers to global i. So under both cases, 10 is printed

6. B

7. D
X - = Y + 1    =>     X = X - (Y+1)    =>     X = X - Y - 1

8. D
malloc allocates the specified number of bytes
realloc increases or decrease the size of the specified block of memory. Reallocates it if needed
calloc allocates the specified number of bytes and initializes them to zero

free         releases the specified block of memory back to the system

9. C

10. A
The exact match is
(a) Bit Set                    (ii) int hashcode( )
(b) Calendar                (i) Time zone getTimezone( )
(c) Time zone               (iv) void setID(String tzName)
(d) Random                 (iii) int nextInt( )

Wednesday, July 31, 2013

Miscellaneous 01

01. ______ is process of extracting previously not known valid and actionable information from large data to make crucial business and strategic decisions.                     [Paper III December 2012]
(A) Data Management
(B) Data base
(C) Data Mining
(D) Meta Data

02. Data Warehouse provides                                             [Paper III June 2012]
(A) Transaction Responsiveness
(B) Storage, Functionality Responsiveness to queries
(C) Demand and Supply Responsiveness
(D) None of the above

03An example of a dictionary-based coding technique is      [Paper III December 2012]
(A) Run-length coding
(B) Huffman coding
(C) Predictive coding
(D) LZW coding



SOLUTIONS
1. C

2. B
A data warehouse is a database used for reporting and data analysis. It is a central repository of data which is created by integrating data from one or more disparate sources. Data warehouses store current as well as historical data and are used for creating trending reports for senior management reporting such as annual and quarterly comparisons.
The data stored in the warehouse are uploaded from the operational systems (such as marketing, sales etc.,). The data may pass through an operational data store for additional operations before they are used in the DW for reporting.

3. D
Run-length Coding is a very simple form of data compression in which runs of data (that is, sequences in which the same data value occurs in many consecutive data elements) are stored as a single data value and count, rather than as the original run.
Huffman coding is an entropy encoding algorithm used for lossless data compression. The term refers to the use of a variable-length code table for encoding a source symbol.
Predictive coding is a tool used mostly in audio signal processing and speech processing for representing the spectral envelope of a digital signal of speech in compressed form, using the information of a linear predictive model.
Lempel–Ziv–Welch (LZW) is a universal lossless data compression algorithm. A high level view of the encoding algorithm is shown here:

  1. Initialize the dictionary to contain all strings of length one.
  2. Find the longest string W in the dictionary that matches the current input.
  3. Emit the dictionary index for W to output and remove W from the input.
  4. Add W followed by the next symbol in the input to the dictionary.
  5. Go to Step 2.

A dictionary is initialized to contain the single-character strings corresponding to all the possible input characters (and nothing else except the clear and stop codes if they're being used). The algorithm works by scanning through the input string for successively longer substrings until it finds one that is not in the dictionary

Monday, July 29, 2013

Graph Theory 01

1. The time complexities of some standard graph algorithms are given. Match each algorithm with its time complexity? (n and m are no. of nodes and edges respectively) [Paper III December 2012]
a. Bellman Ford algorithm                  1. O (m log n)
b. Kruskals algorithm                         2. O (n3)
c. Floyd Warshall algorithm               3. O(mn)
d. Topological sorting                        4. O(n + m)
Codes:
a          b          c          d
(A)       3          1          2          4
(B)       2          4          3          1
(C)       3          4          1          2
(D)       2          1          3          4

2. Two graphs A and B are shown below: Which one of the following statement is true? 
[Paper III December 2012]

(A) Both A and B are planar.
(B) Neither A nor B is planar.
(C) A is planar and B is not.
(D) B is planar and A is not.

3. Maximum number of edges in a n Node undirected graph without self loop is:  
[Paper II December 2011]
(A) n2                             (B) n(n – 1)
(C) n(n + 1)                    (D) n(n – 1)/2

4. Consider a weighted undirected graph with positive edge weights and let (u, v) be an edge in the graph. It is known that the shortest path from source vertex s to u has weight 53 and shortest path from s to v has weight 65. Which statement is always true?              [Paper III June 2012]
(A) Weight (u, v)  12              (B) Weight (u, v) = 12
(C) Weight (u, v) ≥ 12            (D) Weight (u, v) > 12

5. G1 and G2 are two graphs as shown:                 [Paper III June 2012]


(A) Both G1 and G2 are planar graphs.
(B) Both G1 and G2 are not planar graphs.
(C) G1 is planar and G2 is not planar graph.
(D) G1 is not planar and G2 is planar graph.

6. The number of colours required to properly colour the vertices of every planer graph is          [Paper II June 2012]
(A) 2                (B) 3

(C) 4                (D) 5

SOLUTIONS
1. A

  • The Bellman–Ford algorithm is an algorithm that computes shortest paths from a single source vertex to all of the other vertices in a weighted digraph. Bellman–Ford runs in O(|V|·|E|) time, where |V| and |E| are the number of vertices and edges respectively.
  • Kruskal's algorithm is a greedy algorithm in graph theory that finds a minimum spanning tree for a connected weighted graph. This means it finds a subset of the edges that forms a tree that includes every vertex, where the total weight of all the edges in the tree is minimized. Where E is the number of edges in the graph and V is the number of vertices, Kruskal's algorithm can be shown to run in O(E log E) time, or equivalently, O(E log V) time.
  • Floyd–Warshall algorithm (also known as Floyd's algorithm, Roy–Warshall algorithm, Roy–Floyd algorithm, or the WFI algorithm) is a graph analysis algorithm for finding shortest paths in a weighted graph with positive or negative edge weights (but with no negative cycles, see below) and also for finding transitive closure of a relation R. the complexity of the algorithm is O(n3).
  • A topological sort of a directed graph is a linear ordering of its vertices such that for every directed edge uv from vertex u to vertex v, u comes before v in the ordering. The usual algorithms for topological sorting have running time linear in the number of nodes plus the number of edges O(|V| + |E|).
2. A
A planar graph is a graph that can be embedded in the plane, i.e., it can be drawn on the plane in such a way that its edges intersect only at their endpoints. In other words, it can be drawn in such a way that no edges cross each other. The given graphs can be redrawn as shown below:


3. D
If you have n nodes, and each node has an edge with n-1 other nodes. However, n(n-1) is double-counting because if two nodes are each connected with the other then that needs to be counted as a single edge. So maximum number of edges is n(n-1)/2.

4. C
The difference in weights to u and v from source is 12. The shortest path to v may or may not include the edge (u, v). Suppose it is included, then the weight(u,v) = 12. And if it is not included, that means there is a path of less weight from u to v, i.e weight(u,v) > 12

5. B

6. C
The Four Color Theorem asserts that every planar graph - and therefore every "map" on the plane or sphere - no matter how large or complex, is 4-colorable