Sei sulla pagina 1di 73

1. What is the range of data type short in Java?

a) -128 to 127
b) -32768 to 32767
c) -2147483648 to 2147483647
d) None of the mentioned
Answer:b
Explanation:Short occupies 16 bits in memory. Its range is from -32768 to 32767.

2. Which of these coding types is used for data type characters in Java?
a) ASCII
b) ISO-LATIN-1
c) UNICODE
d) None of the mentioned
Answer:c
Explanation: Unicode defines fully international character set that can represent all the
characters found in all human languages. Its range is from 0 to 65536.

3. Which one is a valid declaration of a boolean?


a) boolean b1 = 1;
b) boolean b2 = false;
c) boolean b3 = false;
d) boolean b4 = true
Answer:c
4.Explanation: Boolean can only be assigned true or false literals.

Which of these is necessary condition for automatic type conversion in Java?


a) The destination type is smaller than source type.
b) The destination type is larger than source type.
c) The destination type can be larger or smaller than source type.
d) None of the mentioned
5. If an expression contains double, int, float, long, then whole expression will
promoted into which of these data types?
a) long
b) int
c) double
d) float
Answer: c
Explanation:If any operand is double the result of expression is double.

6. Which of these operators is used to allocate memory to array variable in Java?


a) malloc
b) alloc
c) new
d) new malloc

Answer:c
Explanation:Operator new allocates block of memory specified by the size of array, and gives
the reference of memory allocated to the array variable.

7. Which of these is not a bitwise operator?


a) &
b) &=
c) |=
d) <= [expand title="View Answer"] Answer:d Explanation: <= is a relational operator.
[/expand] 2. Which operator is used to invert all the digits in binary representation of
a number? a) ~ b) <<< c) >>>
d) ^
Answer:a
Explanation: Unary not operator, ~, inverts all of the bits of its operand in binary
representation.

8. What is the output of this program?


class ternary_operator {
public static void main(String args[])
{
int x = 3;
int y = ~ x;
int z;
z = x > y ? x : y;
System.out.print(z);
}
}

a) 0
b) 1
c) 3
d) -4
9. What is the stored in the object obj in following lines of code?
box obj;
a) Memory address of allocated memory of object.
b) NULL
c) Any arbitrary pointer
d) Garbage
Answer: b
Explanation: Memory is allocated to an object using new operator. box obj; just declares a
reference to object, no memory is allocated to it hence it points to NULL.

10. What is the return type of Constructors?


a) int
b) float
c) void
d) None of the mentioned
nswer: d
Explanation: Constructors does not have any return type, not even void.

11. Which function is used to perform some action when the object is to be
destroyed?
a) finalize()
b) delete()
c) main()
d) None of the mentioned
12. Which of the folowing stements are incorrect?
a) Default constructor is called at the time of declaration of the object if a constructor
has not been defined.
b) Constructor can be parameterized.
c) finalize() method is called when a object goes out of scope and is no longer
needed.
d) finalize() method must be declared protected.
Answer: c
Explanation: finalize() method is called just prior to garbage collection. it is not called when
object goes out of scope.

13. Which of these keyword must be used to inherit a class?


a) super
b) this
c) extent
d) extends
Answer: b
Explanation: whenever a subclass needs to refer to its immediate superclass, it can do so by
use of the keyword super.

14. A class member declared protected becomes member of subclass of which type?
a) public member
b) private member
c) protected member
d) static member
Answer: b
Explanation: A class member declared protected becomes private member of subclass.

15. What is the output of this program?


class A {
int i;
void display() {

System.out.println(i);
}
}
class B extends A {
int j;
void display() {
System.out.println(j);
}
}
class inheritance_demo {
public static void main(String args[])
{
B obj = new B();
obj.i=1;
obj.j=2;
obj.display();
}
}

a) 0
b) 1
c) 2
d) Compilation Error
Answer: c
Explanation: class A & class B both contain display() method, class B inherits class A, when
display() method is called by object of class B, display() method of class B is executed rather
than that of Class A.

16. Which of these class is superclass of String and StringBuffer class?


a) java.util
b) java.lang
c) ArrayList
d) None of the mentioned
Answer: b

17. Which of these method of class String is used to obtain length of String object?
a) get()
b) Sizeof()
c) lengthof()
d) length()
Answer: c

18. Which of these is an oncorrect statement?


a) String objects are immutable, they cannot be changed.
b) String object can point to some other reference of String variable.

c) StringBuffer class is used to store string in a buffer for later use.


d) None of the mentioned
Answer: c
Explanation: StringBuffer class is used to create strings that can be modified after they are
created.

19. What is the output of this program?


class String_demo {
public static void main(String args[])
{
int ascii[] = { 65, 66, 67, 68};
String s = new String(ascii, 1, 3);
System.out.println(s);
}
}

a) ABC
b) BCD
c) CDA
d) ABCD
Answer: b
Explanation: ascii is an array of integers which contains ascii codes of Characters A, B, C, D.
String(ascii, 1, 3) is an constructor which initializes s with Characters corresponding to ascii
codes stored in array ascii, starting position being given by 1 & ending position by 3, Thus s
stores BCD.
output:
$ javac String_demo.java
$ java String_demo
BCD

20. What will s2 contain after following lines of code?


StringBuffer s1 = one;
StringBuffer s2 = s1.append(two)
a) one
b) two
c) onetwo
d) twoone
Answer: c
Explanation: Two strings can be concatenated by using append() method.

21. Which of these method of class StringBuffer is used to get the length of
sequence of characters?
a) length()
b) capacity()
c) Length()
d) Capacity()

Answer: a
Explanation: length()- returns the length of String the StringBuffer would create whereas
capacity() returns total number of characters that can be supported before it is grown.
22.What will be the output of following
class output {
public static void main(String args[])
{
StringBuffer c = new StringBuffer("Hello");
System.out.println(c.length());
}
}
a) 4
b) 5
c) 6
d) 7
Explanation: length() method is used to obtain length of StringBuffer object, length of Hello
is 5.
Output:
$ javac output.java
$ java output
5

23. Which of these class is used to make a thread?


a) String
b) System
c) Thread
d) Runnable
Answer: c
Explanation: Thread class is used to make threads in java, Thread encapsulates a thread of
execution. To create a new thread the program will either extend Thread or implement the
Runnable interface.

24. Which of these method of Thread class is used to find out the priority given to a
thread?
a) get()
b) ThreadPriority()
c) getPriority()
d) getThreadPriority()
Answer: c
Explanation: None.

25. Which function of pre defined class Thread is used to check weather current
thread being checked is still running?
a) isAlive()
b) Join()
c) isRunning()
d) Alive()
Answer:a
Explanation:isAlive() function is defined in class Thread, it is used for implementing
multithreading and to check whether the thread called
upon is still running or no

26.What is the priority of the thread in output of this program?


class multithreaded_programing {
public static void main(String args[]) {
Thread t = Thread.currentThread();
t.setName("New Thread");
System.out.println(t.getName());
}

a) main
b) Thread
c) New Thread
d) Thread[New Thread,5,main]
Answer: c
Explanation: The getName() function is used to obtain the name of the thread, in this code the
name given to thread is New Thread.
Output:
$ javac multithreaded_programing.java
$ java multithreaded_programing
New Thread

27.Which of these keywords is used to generate an exception explicitly?


a) try
b) finally
c) throw
d) catch
Answer: c
Explanation: None.

28.. Which of these operator is used to generate an instance of an exception than


can be thrown by using throw?
a) new
b) malloc
c) alloc
d) thrown
Answer: a
Explanation: new is used to create instance of an exception. All of javas built in run-time
exceptions have two constructors : one with no parameters and one that takes a string
parameter.

29. Which of these keywords is used to by the calling function to guard against the
exception that is thrown by called function?
a) try
b) throw
c) throws
d) catch

30.What is the output of this program?


class exception_handling {
public static void main(String args[]) {
try {
throw new NullPointerException ("Hello");
System.out.print("A");
}
catch(ArithmeticException e) {
System.out.print("B");
}
}
}

a) A
b) B
c) Hello
d) Runtime Error
31.Which of these functions is called to display the output of an applet?
a) display()
b) print()
c) displayApplet()
d) PrintApplet()

Answer: b
Explanation: Whenever the applet requires to redraw its output, it is done by using method
paint().

32. What is the Message is displayed in the applet made by this program?
import java.awt.*;
import java.applet.*;
public class myapplet extends Applet {
public void paint(Graphics g) {
g.drawString("A Simple Applet", 20, 20);
}
}

a) A Simple Applet
b) A Simple Applet 20 20
c) Compilation Error
d) Runtime Erro
Answer: a
Explanation: None.
Output:
A Simple Applet
(Output comes in a new java application)

33. Which of these is used to perform all input & output operations in Java?
a) streams
b) Variables
c) classes
d) Methods
Answer: a
Explanation: Like in any other language, streams are used for input and output operations.

34. Which of these classes are used by Byte streams for input and output operation?
a) InputStream
b) InputOutputStream
c) Reader
d) All of the mentioned
Answer: a
Explanation: Byte stream uses InputStream and OutputStream classes for input and output
operation.

35.What is the output of this program if input given is abcqfghqbcd?


class Input_Output {
public static void main(String args[]) throws IOException {
char c;

BufferedReader obj = new BufferedReader(new InputStreamReader(System.in));


do {
c = (char) obj.read();
System.out.print(c);
} while(c != 'q');
}
}

a) abcqfgh
b) abc
c) abcq
d) abcqfghq
Answer: c
Explanation: None.
Output:
$ javac Input_Output.java
$ java Input_Output
abcq

36. Which of these class object can be used to form a dynamic array?
a) ArrayList
b) Map
c) Vector
d) ArrayList & Map

Answer: d
Explanation: Vectors are dynamic arrays, it contains many legacy methods that are not part
of collection framework, and hence these methods are not present in ArrayList. But both are
used to form dynamic arrays.

37. What is the name of data member of class Vector which is used to store number
of elements in the vector?
a) length
b) elements
c) elementCount
d) capacity
Answer: c
Explanation: None.

38. What is the output of this program?


import java.util.*;
class vector {
public static void main(String args[]) {
Vector obj = new Vector(4,2);
obj.addElement(new Integer(3));
obj.addElement(new Integer(2));
obj.addElement(new Integer(5));
System.out.println(obj.capacity());
}
}

a) 2
b) 3
c) 4
d) 6
Answer: c
Explanation: None.
Output:
$ javac vector.java
$ java vector
4

39. Which of these method is used to begin the execution of a thread?


a) run()
b) start()
c) runThread()
d) startThread()

Answer: b
Explanation: None.

40. Which of these statements is incorrect?


a) By multithreading CPUs idle time is minimized, and we can take maximum use of
it.
b) By multitasking CPUs idle time is minimized, and we can take maximum use of it.
c) Two thread in Java can have same priority
d) A thread can exist only in two states, running and blocked
Answer: d
Explanation: Thread exist in several states, a thread can be running, suspended, blocked,
terminated & ready to run

41.____ converts the programs written in assembly language into machine


instructions .
a) Machine compiler
b) Interpreter
c) Assembler
d) Converter
Answer:c
Explanation: The assembler is a software used to convert the programs into machine

instructions.
42. To overcome the problems of the assembler in dealing with branching code we
use _____ .
a) Interpreter
b) Debugger
c) Op-Assembler
d) Two-pass assembler
Answer:d
Explanation: This creates entries into the symbol table first and then creates the object

code.
43 . The assembler stores all the names and their corresponding values in ______ .
a) Special purpose Register
b) Symbol Table
c) Value map Set
d) None of the above
Explanation: The table where the assembler stores the variable names along with their

corresponding memory locations and values.

44) In a two pass assembler the pseudo code EQU is to be evaluated


during ?
a.
b.
c.
d.

Pass 1
Pass 2
not evaluated by the assembler
None of above

Ans-A
45) Which of the following system software resides in the main memory
always ?
a.
b.
c.
d.

Text editor
Assembler
Linker
Loader

Ans_D
46) Parsing is also known as ?
a.
b.
c.
d.

Lexical analysis
Syntax analysis
Semantic analysis
Code generation

47) Indicate which of the following is not true about interpreter ?


a.
b.
c.
d.
e.

Interpreter generate an object program from the source program


Interpreter analyses each source statement every time it is to be executed
Interpreter is a kind of translator
All of above
None of above

Ans.A
48) Bottom up parsing involves ?
a.
b.
c.
d.

Shift reduce
Handle pruning
Operator check
A and B

Answer = D

3) The linker ?
a.

is same as the loader

b. is required to create a load module


c. is always used before programs are executed
d. None of abo
Answer-b

49) In a two pass assembler the object code generation is done during the ?
a.
b.
c.
d.

Second pass
First pass
Zeroeth pass
Not done by assembler

Ans.A.
50.compiler for a high level language that runs on one machine and produce code for
different machine is called

a.
b.
c.
d.

Optimizing compiler
One pass compiler
Cross compiler
Multipass compiler

Ans.C
4) Which of the following is not a type of assembler ?
a.
b.
c.
d.

one pass
two pass
three pass
Non of Above

Ans-C

7) Yacc semantic action is a sequence of ?


a.
b.
c.
d.

Tokens
Expression
C statement
Rules

Answer = C

10) A Compiler has ....... phases ?


a.
b.
c.
d.

Ans.C.

7
6
8
None of above

(18) In a compiler _______________ checks every character of the source text.


(A) The lexical analyzer
(B) The syntax analyzer
(C) The code generator
(D) The code optimizer
ANSWER: The lexical analyzer
1. Which of these keywords is used to define packages in Java?
a) pkg
b) Pkg
c) package
d) Package
Answer: c

2. Which of these is a mechanism for naming and visibility control of a class and its
content?
a) Object
b) Packages
c) Interfaces
d) None of the Mentioned.
Answer: b
Explanation: Packages are both naming and visibility control mechanism. We can define a
class inside a package which is not accessible by code outside the package.

3. Which of this access specifies can be used for a class so that its members can be
accessed by a different class in the same package?
a) Public
b) Protected
c) No Modifier
d) All of the mentioned
Answer: d
Explanation: Either we can use public, protected or we can name the class without any
specifier.

4. Which of these access specifiers can be used for a class so that its
members can be accessed by a different class in the different package?
a) Public
b) Protected
c) Private

d) No Modifier
View Answer
Answer: a
Explanation: None.

5. Which of the following is correct way of importing an entire package


pkg?
a) import pkg.
b) Import pkg.
c) import pkg.*
d) Import pkg.*
View Answer
Answer: c
Explanation: Operator * is used to import the entire package.

6. Which of the following is incorrect statement about packages?


a) Package defines a namespace in which classes are stored.
b) A package can contain other package within it.
c) Java uses file system directories to store packages.
d) A package can be renamed without renaming the directory in which the
classes are stored.
View Answer
Answer: d
Explanation: A package can be renamed only after renaming the directory in which the
classes are stored.
7. Which of the following package stores all the standard java classes?
a) lang
b) java
c) util
d) java.packages
View Answer

8. What is the output of this program?


1.
2.
3.
4.
5.
6.

package pkg;
class display {
int x;
void show() {
if (x > 1)
System.out.print(x + " ");

7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.

}
}
class packages {
public static void main(String args[]) {
display[] arr=new display[3];
for(int i=0;i<3;i++)
arr[i]=new display();
arr[0].x = 0;
arr[1].x = 1;
arr[2].x = 2;
for (int i = 0; i < 3; ++i)
arr[i].show();
}
}

Note : packages.class file is in directory pkg;


a) 0
b) 1
c) 2
d) 0 1 2
View Answer
Answer: c
Explanation: None.
Output:
$ javac packages.java
$ java packages
2

9. What is the output of this program?


1.
2.
3.
4.
5.
6.
7.
8.
9.

package pkg;
class output {
public static void main(String args[])
{
StringBuffer s1 = new StringBuffer("Hello");
s1.setCharAt(1, x);
System.out.println(s1);
}
}

advertisements
a) xello
b) xxxxx
c) Hxllo

d) Hexlo
View Answer
Answer: c
Explanation: None.
Output:
$ javac output.java
$ java output
Hxllo

10. What is the output of this program?


1.
2.
3.
4.
5.
6.
7.
8.
9.

package pkg;
class output {
public static void main(String args[])
{
StringBuffer s1 = new StringBuffer("Hello World");
s1.insert(6 , "Good ");
System.out.println(s1);
}
}

Note : Output.class file is not in directory pkg.


a) HelloGoodWorld
b) HellGoodoWorld
c) Compilation error
d) Runtime error
View Answer
Answer: d
Explanation: Since output.class file is not in the directory pkg in which class output is
defined, program will not be able to run.
output:
$ javac output.java
$ java output
can not find file output.class

1. Which of these is a wrapper for data type int?


a) Integer
b) Long
c) Byte
d) Double
View Answer

Answer: a
Explanation: None.

2. Which of the following methods is a method of wrapper Integer for


obtaining hash code for the invoking object?
a) int hash()
b) int hashcode()
c) int hashCode()
d) Integer hashcode()
View Answer
Answer: c
Explanation: None.

3. Which of these is a super class of wrappers Long, Character & Integer?


a) Long
b) Digits
c) Float
d) Number
View Answer
Answer: d
Explanation: Number is an abstract class containing subclasses Double, Float, Byte, Short,
Integer and Long.

4. Which of these is wrapper for simple data type char?


a) Float
b) Character
c) String
d) Integer
View Answer
Answer: b
Explanation: None.

5. Which of the following is method of wrapper Integer for converting the


value of an object into byte?
a) bytevalue()
b) byte bytevalue()
c) Bytevalue()
d) Byte Bytevalue().
View Answer

6. Which of these methods is used to obtain value of invoking object as a


long?
a) long value()
b) long longValue()
c) Long longvalue()
d) Long Longvalue()
View Answer
7. What is the output of this program?
1.
2.
3.
4.
5.
6.
7.
8.

class Output {
public static void main(String args[]) {
char a[] = {'a', '5', 'A', ' '};
System.out.print(Character.isDigit(a[0]) + " ");
System.out.print(Character.isWhitespace(a[3]) + " ");
System.out.print(Character.isUpperCase(a[2]));
}
}

advertisements
a) true false true
b) false true true
c) true true false
d) false false false
View Answer
Answer: b
Explanation: Character.isDigit(a[0]) checks for a[0], whether it is a digit or not, since a[0] i:e
a is a character false is returned. a[3] is a whitespace hence Character.isWhitespace(a[3])
returns a true. a[2] is an upper case letter i:e A hence Character.isUpperCase(a[2]) returns
true.
Output:
$ javac Output.java
$ java Output
false true true

8. What is the output of this program?


1.
2.
3.
4.
5.
6.
7.

class Output {
public static void main(String args[]) {
Integer i = new Integer(257);
byte x = i.byteValue();
System.out.print(x);
}
}

a) 0
b) 1
c) 256
d) 257
View Answer
Answer: b
Explanation: i.byteValue() method returns the value of wrapper i as a byte value. i is 257,
range of byte is 256 therefore i value exceeds byte range by 1 hence 1 is returned and
stored in x.
Output:
$ javac Output.java
$ java Output
1

9. What is the output of this program?


1.
2.
3.
4.
5.
6.
7.

class Output {
public static void main(String args[]) {
Integer i = new Integer(257);
float x = i.floatValue();
System.out.print(x);
}
}

advertisements
a) 0
b) 1
c) 257
d) 257.0
View Answer
Answer: d
Explanation: None.
Output:
$ javac Output.java
$ java Output
257.0

10. What is the output of this program?


1.
2.
3.
4.
5.
6.

class Output {
public static void main(String args[]) {
Long i = new Long(256);
System.out.print(i.hashCode());
}
}

a) 256
b) 256.0
c) 256.00
d) 257.00
View Answer
Answer: a
Explanation: None.
Output:
$ javac Output.java
$ java Output
256

1. Which of these is a super class of all exceptional type classes?


a) String
b) RuntimeExceptions
c) Throwable
d) Cachable
View Answer
Answer: c
Explanation: All the exception types are subclasses of the built in class Throwable.

2. Which of these class is related to all the exceptions that can be caught
by using catch?
a) Error
b) Exception
c) RuntimeExecption
d) All of the mentioned
View Answer
Answer: b
Explanation: Error class is related to java run time error that cant be caught usually,
RuntimeExecption is subclass of Exception class which contains all the exceptions that can
be caught.

3. Which of these class is related to all the exceptions that cannot be


caught?
a) Error
b) Exception

c) RuntimeExecption
d) All of the mentioned
View Answer
Answer: a
Explanation: Error class is related to java run time error that cant be caught usually,
RuntimeExecption is subclass of Exception class which contains all the exceptions that can
be caught.

4. Which of these handles the exception when no catch is used?


a) Default handler
b) finally
c) throw handler
d) Java run time system
View Answer
Answer: a
Explanation: None.

5. Which of these keywords is used to manually throw an exception?


a) try
b) finally
c) throw
d) catch
View Answer
Answer: c
Explanation: None.

6. What is the output of this program?


1.
2.
3.
4.
5.
6.
7.
8.
9.
10.

class exception_handling {
public static void main(String args[]) {
try {
System.out.print("Hello" + " " + 1 / 0);
}
finally {
System.out.print("World");
}
}
}

advertisements
a) Hello
b) World
c) Compilation Error

d) First Exception then World


View Answer
Answer: d
Explanation: None.
Output:
$ javac exception_handling.java
$ java exception_handling
Exception in thread main java.lang.ArithmeticException: / by zero
World

7. What is the output of this program?


1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.

class exception_handling {
public static void main(String args[]) {
try {
int a, b;
b = 0;
a = 5 / b;
System.out.print("A");
}
catch(ArithmeticException e) {
System.out.print("B");
}
}
}

a) A
b) B
c) Compilation Error
d) Runtime Error
View Answer
Answer: b
Explanation: None.
Output:
$ javac exception_handling.java
$ java exception_handling
B

8. What is the output of this program?


1.
2.
3.
4.
5.

class exception_handling {
public static void main(String args[]) {
try {
int a[] = {1, 2,3 , 4, 5};
for (int i = 0; i < 7; ++i)

6.
7.
8.
9.
10.
11.
12.

System.out.print(a[i]);
}
catch(ArrayIndexOutOfBoundsException e) {
System.out.print("0");
}
}
}

a) 12345
b) 123450
c) 1234500
d) Compilation Error
View Answer
Answer: b
Explanation: When array index goes out of bound then ArrayIndexOutOfBoundsException
exceptio is thrown by the system.
Output:
$ javac exception_handling.java
$ java exception_handling
123450
advertisements
9. What is the output of this program?
1.
class exception_handling {
2.
public static void main(String args[]) {
3.
try {
4.
int i, sum;
5.
sum = 10;
6.
for (i = -1; i < 3 ;++i)
7.
sum = (sum / i);
8.
}
9.
catch(ArithmeticException e) {
10.
System.out.print("0");
11.
}
12.
System.out.print(sum);
13.
}
14.
}

a) 0
b) 05
c) Compilation Error
d) Runtime Error
View Answer

Answer: c
Explanation: Since sum is declared inside try block and we are trying to access it outside the
try block it results in error.
Output:
$ javac exception_handling.java
Exception in thread main java.lang.Error: Unresolved compilation problem:
sum cannot be resolved to a variable

10. What is the output of this program?


1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.

class exception_handling {
public static void main(String args[]) {
try {
int a[] = {1, 2,3 , 4, 5};
for (int i = 0; i < 5; ++i)
System.out.print(a[i]);
int x = 1/0;
}
catch(ArrayIndexOutOfBoundsException e) {
System.out.print("A");
}
catch(ArithmeticException e) {
System.out.print("B");
}
}
}

a) 12345
b) 12345A
c) 12345B
d) Comiplation Error
View Answer
Answer: c
Explanation: There can be more than one catch for a single try block. Here Arithmetic
exception(/ by 0) occurs instead of Array index out of bound exception, so 2nd catch block is
executed.
Output:
$ javac exception_handling.java
$ java exception_handling
12345B

1. What is multithreaded programming?


a) Its a process in which two different processes run simultaneously.
b) Its a process in which two or more parts of same process run
simultaneously.
c) Its a process in which many different process are able to access same
information.
d) Its a process in which a single process can access information from
many sources.
View Answer
Answer: b
Explanation: multithreaded programming a process in which two or more parts of same
process run simultaneously.

2. Which of these are types of multitasking?


a) Process based
b) Thread based
c) Process and Thread based
d) None of the mentioned
View Answer
Answer: c
Explanation: There are two types of multitasking: Process based multitasking and Thread
based multitasking.

3. Which of these packages contain all the Javas built in exceptions?


a) java.io
b) java.util
c) java.lang
d) java.net
View Answer
Answer: c
Explanation: None.

4. Thread priority in Java is?


a) Integer
b) Float
c) double
d) long
View Answer

Answer: a
Explanation: Java assigns to each thread a priority that determines hoe that thread should
be treated with respect to others. Thread priority are integers that specify relative priority of
one thread to another.

5. What will happen if two thread of same priority are called to be


processed simultaneously?
a) Any one will be executed first lexographically
b) Both of them will be executed simultaneously
c) None of them will be executed
d) It is dependent on the operating system.
View Answer
Answer: d
Explanation: In cases where two or more thread with same priority are competing for CPU
cycles, different operating system handle this situation differently. Some execute them in time
sliced manner some depending on the thread they call.

6. Which of these statements is incorrect?


a) By multithreading CPUs idle time is minimized, and we can take
maximum use of it.
b) By multitasking CPUs idle time is minimized, and we can take maximum
use of it.
c) Two thread in Java can have same priority
d) A thread can exist only in two states, running and blocked.
View Answer
7. What is the output of this program?
1.
2.
3.
4.
5.
6.

class multithreaded_programing {
public static void main(String args[]) {
Thread t = Thread.currentThread();
System.out.println(t);
}
}

advertisements
a) Thread[5,main] b) Thread[main,5] c) Thread[main,0] d) Thread[main,5,main] View Answer

8. What is the priority of the thread in output of this program?


1.
2.
3.
4.

class multithreaded_programing {
public static void main(String args[]) {
Thread t = Thread.currentThread();
System.out.println(t);

5.
6.

}
}

a) 4
b) 5
c) 0
d) 1
View Answer
Answer: b
Explanation: The output of program is Thread[main,5,main], in this priority assigned to the
thread is 5. Its the default value. Since we have not named the thread they are named by the
group to they belong i:e main method.
Output:
$ javac multithreaded_programing.java
$ java multithreaded_programing
Thread[main,5,main]

9. What is the name of the thread in output of this program?


1.
2.
3.
4.
5.
6.

class multithreaded_programing {
public static void main(String args[]) {
Thread t = Thread.currentThread();
System.out.println(t);
}
}

advertisements
a) main
b) Thread
c) System
d) None of the mentioned
View Answer
Answer: a
Explanation: The output of program is Thread[main,5,main], Since we have not explicitly
named the thread they are named by the group to they belong i:e main method. Hence they
are named main.
Output:
$ javac multithreaded_programing.java
$ java multithreaded_programing
Thread[main,5,main]

10. What is the name of the thread in output of this program?


1.
2.
3.
4.

class multithreaded_programing {
public static void main(String args[]) {
Thread t = Thread.currentThread();
System.out.println(t.isAlive());

5.
6.

}
}

a) 0
b) 1
c) true
d) false
View Answer
Answer: a
Explanation: Thread t is seeded to currently program, hence when you run the program the
thread becomes active & code t.isAlive returns true.
Output:
$ javac multithreaded_programing.java
$ java multithreaded_programing
true

1. Which of these functions is called to display the output of an applet?


a) display()
b) print()
c) displayApplet()
d) PrintApplet()
View Answer
Answer: b
Explanation: Whenever the applet requires to redraw its output, it is done by using method
paint().

2. Which of these methods can be used to output a sting in an applet?


a) display()
b) print()
c) drawString()
d) transient()
View Answer
Answer: c
Explanation: drawString() method is defined in Graphics class, it is used to output a string in
an applet.

3. What does AWT stands for?


a) All Window Tools
b) All Writing Tools

c) Abstract Window Toolkit


d) Abstract Writing Toolkit
View Answer
Answer: c
Explanation: AWT stands for Abstract Window Toolkit, it is used by applets to interact with the
user.

4. Which of these methods is a part of Abstract Window Toolkit (AWT) ?


a) display()
b) print()
c) drawString()
d) transient()
View Answer
Answer: b
Explanation: paint() is an abstract method defined in AWT.

5. Which of these modifiers can be used for a variable so that it can be


accessed from any thread or parts of a program?
a) transient
b) volatile
c) global
d) No modifier is needed
View Answer
Answer: b
Explanation: The volatile modifier tells the compiler that the variable modified by volatile can
be changed unexpectedly by other part of the program. Specially used in situations involving
multithreading.

6. Which of these operators can be used to get run time information about
an object?
a) getInfo
b) Info
c) instanceof
d) getinfoof
View Answer
Answer: c
Explanation: None.

7. What is the Message is displayed in the applet made by this program?

1.
2.
3.
4.
5.
6.
7.

import java.awt.*;
import java.applet.*;
public class myapplet extends Applet {
public void paint(Graphics g) {
g.drawString("A Simple Applet", 20, 20);
}
}

advertisements
a) A Simple Applet
b) A Simple Applet 20 20
c) Compilation Error
d) Runtime Error
View Answer
Answer: a
Explanation: None.
Output:
A Simple Applet
(Output comes in a new java application)

8. What is the length of the application box made by this program?


1.
2.
3.
4.
5.
6.
7.

import java.awt.*;
import java.applet.*;
public class myapplet extends Applet {
public void paint(Graphics g) {
g.drawString("A Simple Applet", 20, 20);
}
}

a) 20
b) 50
c) 100
d) System dependent
View Answer
Answer: a
Explanation: the code in pain() method g.drawString(A Simple Applet,20,20); draws a
applet box of length 20 and width 20.

9. What is the length of the application box made by this program?


1.
2.
3.
4.
5.
6.

import java.awt.*;
import java.applet.*;
public class myapplet extends Applet {
Graphic g;
g.drawString("A Simple Applet", 20, 20);
}

advertisements
a) 20
b) Default value
c) Compilation Error
d) Runtime Error
View Answer
Answer: c
Explanation: To implement the method drawString we need first need to define abstract
method of AWT that is paint() method. Without paint() method we can not define and use
drawString or any Graphic class methods.

10. What is the output of this program?


1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.

import java.io.*;
class Chararrayinput {
public static void main(String[] args) {
String obj = "abcdefgh";
int length = obj.length();
char c[] = new char[length];
obj.getChars(0, length, c, 0);
CharArrayReader input1 = new CharArrayReader(c);
CharArrayReader input2 = new CharArrayReader(c, 1, 4);
int i;
int j;
try {
while((i = input1.read()) == (j = input2.read())) {
System.out.print((char)i);
}
}
catch (IOException e) {
e.printStackTrace();
}
}
}

a) abc
b) abcd
c) abcde
d) None of the mentioned
View Answer
Answer: d
Explanation: No output is printed. CharArrayReader object input1 contains string abcdefgh
whereas object input2 contains string bcde, when
while((i=input1.read())==(j=input2.read())) is executed the starting character of each object is

compared since they are unequal control comes out of loop and nothing is printed on the
screen.
Output:
$ javac Chararrayinput.java
$ java Chararrayinput

1. Which of these class contains the methods used to write in a file?


a) FileStream
b) FileInputStream
c) BUfferedOutputStream
d) FileBufferStream
View Answer
Answer: b
Explanation: None.
2. Which of these exception is thrown in cases when the file specified for writing it not
found?
a) IOException
b) FileException
c) FileNotFoundException
d) FileInputException
View Answer
Answer: c
Explanation: In cases when the file specified is not found, then FileNotFoundException is
thrown by java run-time system, earlier versions of java used to throw IOException but
after Java 2.0 they throw FileNotFoundException.
3. Which of these methods are used to read in from file?
a) get()
b) read()
c) scan()
d) readFileInput()
View Answer
Answer: b
Explanation: Each time read() is called, it reads a single byte from the file and returns the
byte as an integer value. read() returns -1 when the end of the file is encountered.
4. Which of these values is returned by read() method is end of file (EOF) is
encountered?
a) 0
b) 1

c) -1
d) Null
View Answer
Answer: c
Explanation: Each time read() is called, it reads a single byte from the file and returns the
byte as an integer value. read() returns -1 when the end of the file is encountered.
5. Which of these exception is thrown by close() and read() methods?
a) IOException
b) FileException
c) FileNotFoundException
d) FileInputOutputException
View Answer
Answer: a
Explanation: Both close() and read() method throw IOException.
6. Which of these methods is used to write() into a file?
a) put()
b) putFile()
c) write()
d) writeFile()
View Answer
Answer: c
Explanation: None.
7. What is the output of this program?
1.
2.
3.
4.

import java.io.*;
class filesinputoutput {
public static void main(String args[]) {
InputStream obj = new
FileInputStream("inputoutput.java");
5.
System.out.print(obj.available());
6.
}
7.
}

advertisements
Note: inputoutput.java is stored in the disk.
a) true
b) false
c) prints number of bytes in file
d) prints number of characters in the file
View Answer
8. What is the output of this program?

1.
2.
3.
4.
5.
6.

import java.io.*;
public class filesinputoutput {
public static void main(String[] args) {
String obj = "abc";
byte b[] = obj.getBytes();
ByteArrayInputStream obj1 = new
ByteArrayInputStream(b);
7.
for (int i = 0; i < 2; ++ i) {
8.
int c;
9.
while((c = obj1.read()) != -1) {
10.
if(i == 0) {
11.
System.out.print(Character.toUpperCase((char)c));
12.
obj2.write(1);
13.
}
14.
}
15.
System.out.print(obj2);
16.
}
17.
}
18.
}

a) AaBaCa
b) ABCaaa
c) AaaBaaCaa
d) AaBaaCaaa
View Answer
Answer: d
Explanation: None.
Output:
$ javac filesinputoutput.java
$ java filesinputoutput
AaBaaCaaa
9. What is the output of this program?
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.

import java.io.*;
class Chararrayinput {
public static void main(String[] args) {
String obj = "abcdef";
int length = obj.length();
char c[] = new char[length];
obj.getChars(0, length, c, 0);
CharArrayReader input1 = new CharArrayReader(c);
CharArrayReader input2 = new CharArrayReader(c, 0, 3);
int i;
try {
while((i = input2.read()) != -1) {
System.out.print((char)i);
}
}
catch (IOException e) {
e.printStackTrace();

18.
19.
20.

advertisements
a) abc
b) abcd
c) abcde
d) abcdef
View Answer
Answer: a
Explanation: None.
Output:
$ javac Chararrayinput.java
$ java Chararrayinput
abc
10. What is the output of this program?
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.

import java.io.*;
class Chararrayinput {
public static void main(String[] args) {
String obj = "abcdefgh";
int length = obj.length();
char c[] = new char[length];
obj.getChars(0, length, c, 0);
CharArrayReader input1 = new CharArrayReader(c);
CharArrayReader input2 = new CharArrayReader(c, 1, 4);
int i;
int j;
try {
while((i = input1.read()) == (j = input2.read()))
{

14.
15.
16.
17.
18.
19.
20.
21.

System.out.print((char)i);
}

}
catch (IOException e) {
e.printStackTrace();
}

a) abc
b) abcd
c) abcde
d) None of the mentioned
View Answer
Answer: d
Explanation: No output is printed. CharArrayReader object input1 contains string
abcdefgh whereas object input2 contains string bcde, when
while((i=input1.read())==(j=input2.read())) is executed the starting character of each

object is compared since they are unequal control comes out of loop and nothing is
printed on the screen.
Output:
$ javac Chararrayinput.java
$ java Chararrayinput

Operating System
.What is operating system?
a) collection of programs that manages hardware resources
b) system service provider to the application programs
c) link to interface the hardware and application programs
d) all of the mentioned
View Answer
Answer:d
Explanation:None.
2. To access the services of operating system, the interface is provided by the
a) system calls
b) API
c) library
d) assembly instructions
View Answer
Answer:a
Explanation:None.
3. Which one of the following is not true?
a) kernel is the program that constitutes the central core of the operating system
b) kernel is the first part of operating system to load into memory during booting
c) kernel is made of various modules which can not be loaded in running operating
system
d) kernel remains in the memory during the entire computer session
View Answer
Answer:c
Explanation:None.
4. Which one of the following error will be handle by the operating system?
a) power failure
b) lack of paper in printer
c) connection failure in the network
d) all of the mentioned
View Answer
Answer:d
Explanation:None.
advertisements
5. The main function of the command interpreter is
a) to get and execute the next user-specified command

b) to provide the interface between the API and application program


c) to handle the files in operating system
d) none of the mentioned
View Answer
Answer:a
Explanation:None.
6. By operating system, the resource management can be done via
a) time division multiplexing
b) space division multiplexing
c) both (a) and (b)
d) none of the mentioned
View Answer
Answer:c
Explanation:None.
7. If a process fails, most operating system write the error information to a
a) log file
b) another running process
c) new file
d) none of the mentioned
View Answer
Answer:a
Explanation:None.
8. Which facility dynamically adds probes to a running system, both in user processes
and in the kernel?
a) DTrace
b) DLocate
c) DMap
d) DAdd
View Answer
Answer:a
Explanation:None.
advertisements
9. Which one of the following is not a real time operating system?
a) VxWorks
b) Windows CE
c) RTLinux
d) Palm OS
View Answer
Answer:d
Explanation:None.

10. The OS X has


a) monolithic kernel
b) hybrid kernel
c) microkernel
d) monolithic kernel with modules
View Answer
Answer:b
Explanation:None.

1) A Process Control Block(PCB) does not contain which of the following :


a) Code
b) Stack
c) Heap
d) Data
e) Program Counter
f) Process State
g) I/O status information
h) bootstrap program
View Answer
Answer: h
Explanation: None.
2) The number of processes completed per unit time is known as __________.
a) Output
b) Throughput
c) Efficiency
d) Capacity
View Answer
Answer: b
Explanation: None.
3) The state of a process is defined by :
a) the final activity of the process
b) the activity just executed by the process
c) the activity to next be executed by the process
d) the current activity of the process
View Answer
Answer: d
Explanation: None.
advertisements

4) Which of the following is not the state of a process ?


a) New
b) Old
c) Waiting
d) Running
e) Ready
f) Terminated
View Answer
Answer: b
Explanation: None.
5) The Process Control Block is :
a) Process type variable
b) Data Structure
c) a secondary storage section
d) a Block in memory
View Answer
Answer: b
Explanation: None.
6) The entry of all the PCBs of the current processes is in :
a) Process Register
b) Program Counter
c) Process Table
d) Process Unit
View Answer
Answer: c
Explanation: None.
7) The degree of multi-programming is :
a) the number of processes executed per unit time
b) the number of processes in the ready queue
c) the number of processes in the I/O queue
d) the number of processes in memory
View Answer
Answer: d
Explanation: None.
advertisements
8) A single thread of control allows the process to perform :
a) only one task at a time
b) multiple tasks at a time
c) All of these
View Answer

Answer: a
Explanation: None.
9) The objective of multi-programming is to : (choose two)
a) Have some process running at all times
b) Have multiple programs waiting in a queue ready to run
c) To minimize CPU utilization
d) To maximize CPU utilization
View Answer
Answer: a and d
Explanation: None.

1) Inter process communication :


a) allows processes to communicate and synchronize their actions when using the same
address space.
b) allows processes to communicate and synchronize their actions without using the same
address space.
c) allows the processes to only synchronize their actions without communication.
d) None of these
View Answer
Answer: b
Explanation: None.
2) Message passing system allows processes to :
a) communicate with one another without resorting to shared data.
b) communicate with one another by resorting to shared data.
c) share data
d) name the recipient or sender of the message
View Answer
Answer: a
Explanation: None.
3) An IPC facility provides atleast two operations : (choose two)
a) write message
b) delete message
c) send message
d) receive message
View Answer
Answer: c and d
Explanation: None.

4) Messages sent by a process :


a) have to be of a fixed size
b) have to be a variable size
c) can be fixed or variable sized
d) None of these
View Answer
Answer: c
Explanation: None.
advertisements
5) The link between two processes P and Q to send and receive messages is called :
a) communication link
b) message-passing link
c) synchronization link
d) All of these
View Answer
Answer: a
Explanation: None.
6) Which of the following are TRUE for direct communication :(choose two)
a) A communication link can be associated with N number of process(N = max. number
of processes supported by system)
b) A communication link can be associated with exactly two processes
c) Exactly N/2 links exist between each pair of processes(N = max. number of processes
supported by system)
d) Exactly one link exists between each pair of processes
View Answer
Answer: b and d
Explanation: None.
7) In indirect communication between processes P and Q :
a) there is another process R to handle and pass on the messages between P and Q
b) there is another machine between the two processes to help communication
c) there is a mailbox to help communication between P and Q
d) None of these
View Answer
Answer: c
Explanation: None.
8) In the non blocking send :
a) the sending process keeps sending until the message is received
b) the sending process sends the message and resumes operation
c) the sending process keeps sending until it receives a message

d) None of these
View Answer
Answer: b
Explanation: None.
9) In the Zero capacity queue : (choose two)
a) the queue has zero capacity
b) the sender blocks until the receiver receives the message
c) the sender keeps sending and the messages dont wait in the queue
d) the queue can store atleast one message
View Answer
Answer: a and b
Explanation: None.
advertisements
10) The Zero Capacity queue :
a) is referred to as a message system with buffering
b) is referred to as a message system with no buffering
c) is referred to as a link
d) None of these
View Answer
Answer: b
Explanation: None.
11) Bounded capacity and Unbounded capacity queues are referred to as :
a) Programmed buffering
b) Automatic buffering
c) User defined buffering
d) No buffering
View Answer
Answer: b
Explanation: None.

1. Which module gives control of the CPU to the process selected by the short-term
scheduler?
a) dispatcher
b) interrupt
c) scheduler
d) none of the mentioned
View Answer

Answer:a
Explanation:None.
2. The processes that are residing in main memory and are ready and waiting to execute
are kept on a list called
a) job queue
b) ready queue
c) execution queue
d) process queue
View Answer
Answer:b
Explanation:None.
3. The interval from the time of submission of a process to the time of completion is
termed as
a) waiting time
b) turnaround time
c) response time
d) throughput
View Answer
Answer:b
Explanation:None.
4. Which scheduling algorithm allocates the CPU first to the process that requests the
CPU first?
a) first-come, first-served scheduling
b) shortest job scheduling
c) priority scheduling
d) none of the mentioned
View Answer
Answer:a
Explanation:None.
advertisements
5. In priority scheduling algorithm
a) CPU is allocated to the process with highest priority
b) CPU is allocated to the process with lowest priority
c) equal priority processes can not be scheduled
d) none of the mentioned
View Answer
Answer:a
Explanation:None.

6. In priority scheduling algorithm, when a process arrives at the ready queue, its priority
is compared with the priority of
a) all process
b) currently running process
c) parent process
d) init process
View Answer
Answer:b
Explanation:None.
7. Time quantum is defined in
a) shortest job scheduling algorithm
b) round robin scheduling algorithm
c) priority scheduling algorithm
d) multilevel queue scheduling algorithm
View Answer
Answer:b
Explanation:None.
8. Process are classified into different groups in
a) shortest job scheduling algorithm
b) round robin scheduling algorithm
c) priority scheduling algorithm
d) multilevel queue scheduling algorithm
View Answer
Answer:d
Explanation:None.
advertisements
9. In multilevel feedback scheduling algorithm
a) a process can move to a different classified ready queue
b) classification of ready queue is permanent
c) processes are not classified into groups
d) none of the mentioned
View Answer
Answer:a
Explanation:None.
10. Which one of the following can not be scheduled by the kernel?
a) kernel level thread
b) user level thread
c) process
d) none of the mentioned
View Answer

Answer:b
Explanation:User level threads are managed by thread library and the kernel in unaware
of them.

1. What is the reusable resource?


a) that can be used by one process at a time and is not depleted by that use
b) that can be used by more than one process at a time
c) that can be shared between various threads
d) none of the mentioned
View Answer
Answer:a
Explanation:None.
2. Which of the following condition is required for deadlock to be possible?
a) mutual exclusion
b) a process may hold allocated resources while awaiting assignment of other resources
c) no resource can be forcibly removed from a process holding it
d) all of the mentioned
View Answer
Answer:d
Explanation:None.
3. A system is in the safe state if
a) the system can allocate resources to each process in some order and still avoid a
deadlock
b) there exist a safe sequence
c) both (a) and (b)
d) none of the mentioned
View Answer
Answer:c
Explanation:None.
4. The circular wait condition can be prevented by
a) defining a linear ordering of resource types
b) using thread
c) using pipes
d) all of the mentioned
View Answer
Answer:a
Explanation:None.

advertisements
5. Which one of the following is the deadlock avoidance algorithm?
a) bankers algorithm
b) round-robin algorithm
c) elevator algorithm
d) karns algorithm
View Answer
Answer:a
Explanation:None.
6. What is the drawback of bankers algorithm?
a) in advance processes rarely know that how much resource they will need
b) the number of processes changes as time progresses
c) resource once available can disappear
d) all of the mentioned
View Answer
Answer:d
Explanation:None.
7. For effective operating system, when to check for deadlock?
a) every time a resource request is made
b) at fixed time intervals
c) both (a) and (b)
d) none of the mentioned
View Answer
Answer:c
Explanation:None.
8. A problem encountered in multitasking when a process is perpetually denied necessary
resources is called
a) deadlock
b) starvation
c) inversion
d) aging
View Answer
Answer:b
Explanation:None.
advertisements
9. Which one of the following is a visual ( mathematical ) way to determine the deadlock
occurrence?
a) resource allocation graph
b) starvation graph
c) inversion graph

d) none of the mentioned


View Answer
Answer:a
Explanation:None.
10. To avoid deadlock
a) there must be a fixed number of resources to allocate
b) resource allocation must be done only once
c) all deadlocked processes must be aborted
d) inversion technique can be used
View Answer
Answer:a
Explanation:None.

1) The number of resources requested by a process :


a) must always be less than the total number of resources available in the system
b) must always be equal to the total number of resources available in the system
c) must not exceed the total number of resources available in the system
d) must exceed the total number of resources available in the system
View Answer
Answer: c
Explanation: None.
2) The request and release of resources are ___________.
a) command line statements
b) interrupts
c) system calls
d) special programs
View Answer
Answer: c
Explanation: None.
3) Multithreaded programs are :
a) lesser prone to deadlocks
b) more prone to deadlocks
c) not at all prone to deadlocks
d) None of these
View Answer
Answer: b
Explanation: Multiple threads can compete for shared resources.

4) For a deadlock to arise, which of the following conditions must hold simultaneously ?
( choose all that apply )
a) Mutual exclusion
b) Starvation
c) Hold and wait
d) No preemption
e) Circular wait
View Answer
Answer: a, c, d and e
Explanation: None.
advertisements
5) For Mutual exclusion to prevail in the system :
a) at least one resource must be held in a non sharable mode
b) the processor must be a uniprocessor rather than a multiprocessor
c) there must be at least one resource in a sharable mode
d) All of these
View Answer
Answer: a
Explanation: If another process requests that resource (non shareable resource), the
requesting process must be delayed until the resource has been released.
6) For a Hold and wait condition to prevail :
a) A process must be not be holding a resource, but waiting for one to be freed, and then
request to acquire it
b) A process must be holding at least one resource and waiting to acquire additional
resources that are being held by other processes
c) A process must hold at least one resource and not be waiting to acquire additional
resources
d) None of these
View Answer
Answer: b
Explanation: None.
7) Deadlock prevention is a set of methods :
a) to ensure that at least one of the necessary conditions cannot hold
b) to ensure that all of the necessary conditions do not hold
c) to decide if the requested resources for a process have to be given or not
d) to recover from a deadlock
View Answer
Answer: a
Explanation: None.

8) For non sharable resources like a printer, mutual exclusion :


a) must exist
b) must not exist
c) may exist
d) None of these
View Answer
Answer: a
Explanation: A printer cannot be simultaneously shared by several processes.
9) For sharable resources, mutual exclusion :
a) is required
b) is not required
c) None of these
View Answer
Answer: b
Explanation: They do not require mutually exclusive access, and hence cannot be
involved in a deadlock.
10) To ensure that the hold and wait condition never occurs in the system, it must be
ensured that :
a) whenever a resource is requested by a process, it is not holding any other resources
b) each process must request and be allocated all its resources before it begins its
execution
c) a process can request resources only when it has none
d) All of these
View Answer
Answer: d
Explanation: c A process may request some resources and use them. Before it can can
request any additional resources, however it must release all the resources that it is
currently allocated.
advertisements
11) The disadvantage of a process being allocated all its resources before beginning its
execution is :
a) Low CPU utilization
b) Low resource utilization
c) Very high resource utilization
d) None of these
View Answer
Answer: b
Explanation: None.
12) To ensure no preemption, if a process is holding some resources and requests another
resource that cannot be immediately allocated to it :

a) then the process waits for the resources be allocated to it


b) the process keeps sending requests until the resource is allocated to it
c) the process resumes execution without the resource being allocated to it
d) then all resources currently being held are preempted
View Answer
Answer: d
Explanation: None.
13) One way to ensure that the circular wait condition never holds is to :
a) impose a total ordering of all resource types and to determine whether one precedes
another in the ordering
b) to never let a process acquire resources that are held by other processes
c) to let a process wait for only one resource at a time
d) All of these
View Answer
Answer: a
Explanation: None.
1. CPU fetches the instruction from memory according to the value of
a) program counter
b) status register
c) instruction register
d) program status word
View Answer
Answer:a
Explanation:None.
2. A memory buffer used to accommodate a speed differential is called
a) stack pointer
b) cache
c) accumulator
d) disk buffer
View Answer
Answer:b
Explanation:None.
3. Which one of the following is the address generated by CPU?
a) physical address
b) absolute address
c) logical address

d) none of the mentioned


View Answer
Answer:c
Explanation:None.
4. Run time mapping from virtual to physical address is done by
a) memory management unit
b) CPU
c) PCI
d) none of the mentioned
View Answer
Answer:a
Explanation:None.
advertisements
5. Memory management technique in which system stores and retrieves data from
secondary storage for use in main memory is called
a) fragmentation
b) paging
c) mapping
d) none of the mentioned
View Answer
Answer:b
Explanation:None.
6. The address of a page table in memory is pointed by
a) stack pointer
b) page table base register
c) page register
d) program counter
View Answer
Answer:b
Explanation:None.
7. Program always deals with
a) logical address
b) absolute address
c) physical address
d) relative address
View Answer
Answer:a
Explanation:None.

8. The page table contains


a) base address of each page in physical memory
b) page offset
c) page size
d) none of the mentioned
View Answer
Answer:a
Explanation:None.
advertisements
9. What is compaction?
a) a technique for overcoming internal fragmentation
b) a paging technique
c) a technique for overcoming external fragmentation
d) a technique for overcoming fatal error
View Answer
Answer:c
Explanation:None.
10. Operating System maintains the page table for
a) each process
b) each thread
c) each instruction
d) each address
View Answer
Answer:a
Explanation:None.
1) In segmentation, each address is specified by :
a) a segment number
b) an offset
c) a value
d) a key
View Answer
2) In paging the user provides only ________, which is partitioned by the hardware into
________ and ______.
a) one address, page number, offset
b) one offset, page number, address
c) page number, offset, address
d) None of these
View Answer

Answer: a
Explanation: None.
3) Each entry in a segment table has a :
a) segment base
b) segment peak
c) segment limit
d) segment value
View Answer
Answer: a and c
Explanation: None.
4) The segment base contains the :
a) starting logical address of the process
b) starting physical address of the segment in memory
c) segment length
d) None of these
View Answer
Answer: b
Explanation: None.
advertisements
5) The segment limit contains the :
a) starting logical address of the process
b) starting physical address of the segment in memory
c) segment length
d) None of these
View Answer
Answer: c
Explanation: None.
6) The offset d of the logical address must be :
a) greater than segment limit
b) between 0 and segment limit
c) between 0 and the segment number
d) greater than the segment number
View Answer
Answer: b
Explanation: None.
7) If the offset is legal :
a) it is used as a physical memory address itself
b) it is subtracted from the segment base to produce the physical memory address
c) it is added to the segment base to produce the physical memory address

d) None of these
View Answer
Answer: a
Explanation: None.
8) When the entries in the segment tables of two different processes point to the same
physical location :
a) the segments are invalid
b) the processes get blocked
c) segments are shared
d) All of these
View Answer
Answer: c
Explanation: None.
9) The protection bit is 0/1 based on : (choose all that apply)
a) write only
b) read only
c) read write
d) None of these
View Answer
Answer: b and c
Explanation: None.
advertisements
10) If there are 32 segments, each of size 1Kb, then the logical address should have :
a) 13 bits
b) 14 bits
c) 15 bits
d) 16 bits
View Answer
Answer: a
Explanation: To specify a particular segment, 5 bits are required. To select a particular
byte after selecting a page, 10 more bits are required. Hence 15 bits are required.
11) Consider a computer with 8 Mbytes of main memory and a 128 K cache. The cache
block size is 4 K. It uses a direct mapping scheme for cache management. How many
different main memory blocks can map onto a given physical cache block ?
a) 2048
b) 256
c) 64
d) 8
View Answer

Answer: c
Explanation: None.
12) A multilevel page table is preferred in comparison to a single level page table for
translating virtual address to physical address because :
a) it reduces the memory access time to read or write a memory location
b) it helps to reduce the size of page table needed to implement the virtual address space
of a process
c) it is required by the translation look aside buffer
d) it helps to reduce the number of page faults in page replacement algorithms
View Answer
Answer: b
Explanation: None.
1) Physical memory is broken into fixed-sized blocks called ________.
a) frames
b) pages
c) backing store
d) None of these
View Answer
Answer: a
Explanation: None.
2) Logical memory is broken into blocks of the same size called _________.
a) frames
b) pages
c) backing store
d) None of these
View Answer
Answer: b
Explanation: None.
3) Every address generated by the CPU is divided into two parts : (choose two)
a) frame bit
b) page number
c) page offset
d) frame offset
View Answer
Answer: b and c
Explanation: None.

4) The __________ is used as an index into the page table.


a) frame bit
b) page number
c) page offset
d) frame offset
View Answer
Answer: b
Explanation: None.
5) The _____ table contains the base address of each page in physical memory.
a) process
b) memory
c) page
d) frame
View Answer
Answer: c
Explanation: None.
advertisements
6) The size of a page is typically :
a) varied
b) power of 2
c) power of 4
d) None of these
View Answer
Answer: b
Explanation: None.
7) If the size of logical address space is 2 to the power of m, and a page size is 2 to the
power of n addressing units, then the high order _____ bits of a logical address designate
the page number, and the ____ low order bits designate the page offset.
a) m, n
b) n, m
c) m n, m
d) m n, n
View Answer
Answer: d
Explanation: None.
8) With paging there is no ________ fragmentation.
a) internal
b) external
c) either type of

d) None of these
View Answer
9) The operating system maintains a ______ table that keeps track of how many frames
have been allocated, how many are there, and how many are available.
a) page
b) mapping
c) frame
d) memory
View Answer
Answer: c
Explanation: None.
10) Paging increases the ______ time.
a) waiting
b) execution
c) context switch
d) All of these
View Answer
Answer: c
Explanation: None.
11) Smaller page tables are implemented as a set of _______.
a) queues
b) stacks
c) counters
d) registers
View Answer
Answer: d
Explanation: None.
advertisements
12) The page table registers should be built with _______.
a) very low speed logic
b) very high speed logic
c) a large memory space
d) None of these
View Answer
Answer: b
Explanation: None.
13) For larger page tables, they are kept in main memory and a __________ points to the
page table.
a) page table base register

b) page table base pointer


c) page table register pointer
d) page table base
View Answer
Answer: a
Explanation: None.
14) For every process there is a __________.
a) page table
b) copy of page table
c) pointer to page table
d) All of these
View Answer
Answer: a
Explanation: None.
15) Time taken in memory access through PTBR is :
a) extended by a factor of 3
b) extended by a factor of 2
c) slowed by a factor of 3
d) slowed by a factor of 2
View Answer
Answer: d
Explanation: None.

Netwroking
1. When collection of various computers seems a single coherent system to its client, then
it is called
a) computer network
b) distributed system
c) both (a) and (b)
d) none of the mentioned
View Answer
Answer:b
Explanation:None.
2. Two devices are in network if
a) a process in one device is able to exchange information with a process in another
device
b) a process is running on both devices
c) PIDs of the processes running of different devices are same
d) none of the mentioned
View Answer
Answer:a
Explanation:None.
3. Which one of the following computer network is built on the top of another network?
a) prior network
b) chief network
c) prime network
d) overlay network
View Answer
Answer:d
Explanation:None.
4. In computer network nodes are
a) the computer that originates the data
b) the computer that routes the data
c) the computer that terminates the data
d) all of the mentioned
View Answer
Answer:d
Explanation:None.
advertisements

5. Communication channel is shared by all the machines on the network in


a) broadcast network
b) unicast network
c) multicast network
d) none of the mentioned
View Answer
Answer:a
Explanation:None.
6. Bluetooth is an example of
a) personal area network
b) local area network
c) virtual private network
d) none of the mentioned
View Answer
Answer:a
Explanation:None.
7. A _____ is a device that forwards packets between networks by processing the routing
information included in the packet.
a) bridge
b) firewall
c) router
d) all of the mentioned
View Answer
Answer:c
Explanation:None.
8. A list of protocols used by a system, one protocol per layer, is called
a) protocol architecture
b) protocol stack
c) protocol suit
d) none of the mentioned
View Answer
Answer:b
Explanation:None.
advertisements
9. Network congestion occurs
a) in case of traffic overloading
b) when a system terminates
c) when connection between two nodes terminates
d) none of the mentioned
View Answer

Answer:a
Explanation:None.
10. Which one of the following extends a private network across public networks?
a) local area network
b) virtual private network
c) enterprise private network
d) storage area network
View Answer
Answer:b
Explanation:None.
This set of Computer Networks Questions & Answers focuses on Network Utilities.
1) Ping can
a) Measure round-trip time
b) Report packet loss
c) Report latency
d) All of the mentioned
View Answer
Answer: d
Explanation: None.
2) Ping sweep is a part of
a) Traceroute
b) Nmap
c) Route
d) Ipconfig
View Answer
Answer: b
Explanation: A ping sweep is a method that can establish a range of IP addresses which
map to live hosts and are mostly used by network scanning tools like nmap.
3) ICMP is used in
a) Ping
b) Traceroute
c) Ifconfig
d) Both a and b
View Answer
Answer: d
Explanation: None.

advertisements
4) _____ command is used to manipulate TCP/IP routing table.
a) route
b) Ipconfig
c) Ifconfig
d) Traceroute
View Answer
Answer: a
Explanation: None.
5) If you want to find the number of routers between a source and destination, the utility
to be used is.
a) route
b) Ipconfig
c) Ifconfig
d) Traceroute
View Answer
Answer: d
Explanation: None.
6) Which of the following is related to ipconfig in Microsoft Windows ?
a) Display all current TCP/IP network configuration values
b) Modify DHCP settings
c) Modify DNS settings
d) All of the mentioned
View Answer
Answer: d
Explanation: None.
7) This allows to check if a domain is available for registration.
a) Domain Check
b) Domain Dossier
c) Domain Lookup
d) None of the mentioned
View Answer
Answer: a
Explanation: None.

1. The size of IP address in IPv6 is


a) 4bytes
b) 128bits

c) 8bytes
d) 100bits
View Answer
Answer: b
Explanation: An IPv6 address is 128 bits long.
2. The header length of an IPv6 datagram is _____.
a) 10bytes
b) 25bytes
c) 30bytes
d) 40bytes
View Answer
Answer: d
Explanation: IPv6 datagram has fixed header length of 40bytes, which results is faster
processing of the datagram.
3. In the IPv6 header,the traffic class field is similar to which field in the IPv4 header?
a) Fragmentation field
b) Fast-switching
c) ToS field
d) Option field
View Answer
Answer: c
Explanation: This field enables to have different types of IP datagram.
4. IPv6 doesnot use ______ type of address
a) Broadcast
b) Multicast
c) Anycast
d) None of the mentioned
View Answer
Answer: a
Explanation: Broadcast has been eliminated in IPv6.
advertisements
5. These are the features present in IPv4 but not in IPv6.
a) Fragmentation
b) Header checksum
c) Options
d) All of the mentioned
View Answer
Answer: d
Explanation: All the features are only present in IPv4 and not IPv6.

6. The ____ field determines the lifetime of IPv6 datagram


a) Hop limit
b) TTL
c) Next header
d) None of the mentioned
View Answer
Answer: a
Explanation: The Hop limit value is decremented by one by a router when the datagram is
forwaded by the router. When the value becomes zero the datagram is discarded.
7. Dual-stack approach refers to
a) Implementing Ipv4 with 2 stacks
b) Implementing Ipv6 with 2 stacks
c) Node has both IPv4 and IPv6 support
d) None of the mentioned
View Answer
Answer: c
Explanation: dual-stack is one of the approach used to support IPv6 in already existing
systems.
8. Suppose two IPv6 nodes want to interoperate using IPv6 datagrams but are connected
to each other by intervening IPv4 routers. The best solution here is
a) use dual-stack approach
b) Tunneling
c) No solution
d) Replace the system
View Answer
Answer: b
Explanation: The IPv4 routers can form a tuunel.
advertisements
9. Teredo is an automatic tunneling technique. In each client the obfuscated IPv4 address
is represented by bits
a) 96 to 127
b) 0 to 63
c) 80 to 95
d) 64 to 79
View Answer
Answer: a
Explanation: Bits 96 to 127 in the datagram represents obfuscated 1Pv4 address.

1. The number of objects in a Web page which consists of 4 jpeg images and HTML text
is ______
a) 4
b) 1
c) 5
d) None of the mentioned
View Answer
Answer: c
Explanation: 4 jpeg images + 1 base HTML file.
2. The default connection type used by HTTP is _____
a) Persistent
b) Non-persistent
c) Either of the mentioned
d) None of the mentioned
View Answer
Answer: a
Explanation: None.
3. The time taken by a packet to travel from client to server and then back to the client is
called ____
a) STT
b) RTT
c) PTT
d) None of the mentioned
View Answer
Answer: b
Explanation: RTT stands for round-trip time.
4. The HTTP request message is sent in ____ part of three-way handshake.
a) First
b) Second
c) Third
d) None of the mentioned
View Answer
Answer: c
Explanation: None.
5. In the process of fetching a web page from a server the HTTP request/response takes
______ RTTs.
a) 2
b) 1

c) 4
d) 3
View Answer
Answer: b
Explanation: None.
advertisements
6. The first line of HTTP request message is called ____
a) Request line
b) Header line
c) Status line
d) Entity line
View Answer
Answer: a
Explanation: The line followed by request line are called header lines and status line is
the initial part of response message.
7. The values GET, POST, HEAD etc are specified in ____ of HTTP message
a) Request line
b) Header line
c) Status line
d) Entity body
View Answer
Answer: a
Explanation: It is specified in the method field of request line in the HTTP request
message.
8. The ______ method when used in the method field, leaves entity body empty.
a) POST
b) GET
c) Both of the mentioned
d) None of the mentioned
View Answer
Answer: b
Explanation: None.
9. The HTTP response message leaves out the requested object when _____ method is
used
a) GET
b) POST
c) HEAD
d) PUT
View Answer

Answer: c
Explanation: None.
10. Find the oddly matched HTTP status codes
a) 200 OK
b) 400 Bad Request
c) 301 Moved permanently
d) 304 Not Found
View Answer
Answer: d
Explanation: 404 Not Found.
11. Which of the following is not correct ?
a) Web cache doesnt has its own disk space
b) Web cache can act both like server and client
c) Web cache might reduce the response time
d) Web cache contains copies of recently requested objects
View Answer
Answer: a
Explanation: None.
advertisements
12. The conditional GET mechanism
a) Imposes conditions on the objects to be requested
b) Limits the number of response from a server
c) Helps to keep a cache upto date
d) None of the mentioned
View Answer
Answer: c
Explanation: None.
13. Which of the following is present in both an HTTP request line and a status line?
a) HTTP version number
b) URL
c) Method
d) None of the mentioned
View Answer
Answer: a
Explanation: None.
1. DHCP (dynamic host configuration protocol) provides _____ to the client.
a) IP address
b) MAC address

c) url
d) none of the mentioned
View Answer
Answer:a
Explanation:None.
2. DHCP is used for
a) IPv6
b) IPv4
c) both (a) and (b)
d) none of the mentioned
View Answer
Answer:c
Explanation:None.
3. The DHCP server
a) maintains a database of available IP addresses
b) maintains the information about client configuration parameters
c) grants a IP address when receives a request from a client
d) all of the mentioned
View Answer
Answer:d
Explanation:None.
4. IP assigned for a client by DHCP server is
a) for a limited period
b) for unlimited period
c) not time dependent
d) none of the mentioned
View Answer
Answer:a
Explanation:None.
advertisements
5. DHCP uses UDP port ____ for sending data to the server.
a) 66
b) 67
c) 68
d) 69
View Answer
Answer:b
Explanation:None.

6. The DHCP server can provide the _______ of the IP addresses.


a) dynamic allocation
b) automatic allocation
c) static allocation
d) all of the mentioned
View Answer
Answer:d
Explanation:None.
7. DHCP client and servers on the same subnet communicate via
a) UDP broadcast
b) UDP unicast
c) TCP broadcast
d) TCP unicast
View Answer
Answer:a
Explanation:None.
8. After obtaining the IP address, to prevent the IP conflict the client may use
a) internet relay chat
b) broader gateway protocol
c) address resolution protocol
d) none of the mentioned
View Answer
Answer:c
Explanation:None.
advertisements
9. What is DHCP snooping?
a) techniques applied to ensure the security of an existing DHCP infrastructure
b) encryption of the DHCP server requests
c) algorithm for DHCP
d) none of the mentioned
View Answer
Answer:a
Explanation:None.
10. If DHCP snooping is configured on a LAN switch, then clients having specific
______ can access the network.
a) MAC address
b) IP address
c) both (a) and (b)
d) none of the mentioned
View Answer

Answer:c
Explanation:None.

Potrebbero piacerti anche