Showing posts with label Unit 4. Show all posts
Showing posts with label Unit 4. Show all posts

Tuesday, August 19, 2014

CS2305 - PROGRAMMING PARADIGM - Unit 4

1. Can you call one constructor from another if a class has multiple constructors
Yes. Use this() syntax.

2. Explain the usage of Java packages.
This is a way to organize files when a project consists of multiple modules. It also helps resolve naming conflicts when different packages have classes with the same names. Packages access level also allows you to protect data from being used by the non-authorized classes.

3. If a class is located in a package, what do you need to change in the OS environment to be able to use it?
You need to add a directory or a jar file that contains the package directories to the CLASSPATH environment variable. Let’s say a class Employee belongs to a package com.xyz.hr; and is located in the file c:/dev/com.xyz.hr.Employee.java. In this case, you’d need to add c:/dev to the variable CLASSPATH. If this class contains themethod main(), you could test it from a command prompt window as follows: c:\>java com.xyz.hr.Employee

4. What’s the difference between J2SDK 1.5 and J2SDK 5.0?
There’s no difference, Sun Microsystems just re-branded this version.

Monday, August 18, 2014

CS2305 - PROGRAMMING PARADIGM - Unit 4

1. How could Java classes direct program messages to the system console, but error messages, say to a file? 
The class System has a variable out that represents the standard output, and the variable err that represents the standard error device. By default, they both point at the system console. This how the standard output could be re-directed: 
Stream st =  new Stream (new  FileOutputStream ("techinterviews_com.txt")); 
System.setErr(st); 
System.setOut(st); 

2. What’s the difference between an interface and an abstract class? 
An abstract class may contain code in method bodies, which is not allowed in an interface. With abstract classes, you have to inherit your class from it and Java does not allow multiple inheritance. On the other hand, you can implement multiple interfaces in your class. 

3. Why would you use a synchronized block vs. synchronized method? 
Synchronized blocks place locks for shorter periods than synchronized methods. 

4. Explain the usage of the keyword transient?
This keyword indicates that the value of this member variable does not have to be serialized with the object. When the class will be de-serialized, this variable will be initialized with a default value of its data type (i.e. zero for integers). 

5. How can you force garbage collection? 
You can’t force GC, but could request it by calling System.gc(). JVM does not guarantee that GC will be started immediately. 

Monday, March 24, 2014

Operating System

71.What is a file? 
A file is a named collection of related information that is recorded on secondary storage.  A file contains either programs ordata. A file has certain "structure" based on its type.
• File attributes: Name, identifier, type, size, location, protection, time, date
• File operations: creation, reading, writing, repositioning, deleting, truncating, appending, renaming
• File types: executable, object, library, source code etc.

72.List the various file attributes. 
A file has certain other attributes, which vary from one operating system to another, buttypically consist of these:Name, identifier, type, location, size, protection, time, date and user identification

73.What are the various file operations? 
The six basic file operations are
• Creating a file
• Writing a file
• Reading a file
• Repositioning within a file
• Deleting a file
• Truncating a file

74.What are the information associated with an open file?
Several pieces of information are associated with an open file which may be:
• File pointer
• File open count
• Disk location of the file
• Access rights

75.What are the different accessing methods of a file? 
The different types of accessing a file are:
• Sequential access: Information in the file is accessed sequentially
• Direct access: Information in the file can be accessed without any particular order.
• Other access methods: Creating index for the file, indexed sequential access method (ISAM) etc.

Sunday, March 23, 2014

Operating System

61.What is virtual memory? 
Virtual memory is a technique that allows the execution of  processes that may not be completely in memory. It is the eparation of user logical memory from physical memory. This separation providesan extremely large virtual memory, when only a smaller physical memory is available.

62.What is Demand paging? 
Virtual memory is commonly implemented by demand paging. In demand paging, the pager brings only those necessary pages into memory instead of swapping in a whole process. Thus it avoids reading into memory pages that will not be used anyway,decreasing the swap time and the amount of physical memory needed.

63.Define lazy swapper. 
Rather than swapping the entire process into main memory, alazy swapper is used. A lazy swapper never swaps a page intomemory unless that page will be needed.

64.What is a pure demand paging?
When starting execution of a process with no pages in memory, the operating system sets the instruction pointer to the first instruction of the process, which is on a non-memory resident page, the process immediately faults for the page. Afterthis page is brought into memory, the process continues to execute, faulting as necessary until every page that it needs isin memory. At that point, it can execute with no more faults. This schema is pure demand paging.

65.Define effective access time. 
Let p be the probability of a page fault (0£p£1). The valueof p is expected to be close to 0; that is, there will be only afew page faults. The effective access time isEffective access time = (1-p) * ma + p * page fault time.ma : memory-access time

Wednesday, March 12, 2014

Computer Network

9. What is rate based design?
            Rate- based design, in which the receiver tells the sender the rate-expressed in either bytes or packets per second – at which it is willing to accept incoming data.

10. Define Gateway.
A device used to connect two separate networks that use different communication protocols.
  
11. What is meant by quality of service?
            The quality of service defines a set of attributes related to the performance of the connection. For each connection, the user can request a particular attribute each service class is associated with a set of attributes.

12.  What are the two categories of QoS attributes?
            The two main categories are,
·         User Oriented
·         Network Oriented

13.  List out the user related attributes?
            User related attributes are SCR – Sustainable Cell Rate PCR – Peak Cell Rate MCR- Minimum Cell Rate CVDT – Cell Variation Delay Tolerance.

Tuesday, March 11, 2014

Computer Networks


1. Explain the main idea of UDP?
             The basic idea is for a source process to send a message to a port and for the destination process to receive the message from a port.

2. What are the different fields in pseudo header?
·         Protocol number
·         Source IP address
·         Destination IP addresses.

3. Define TCP?
               TCP guarantees the reliable, in order delivery of a stream of bytes. It is a full-duplex protocol, meaning that each TCP connection supports a pair of byte streams, one flowing in each direction.

4. Define Congestion Control?
               It involves preventing too much data from being injected into the network, thereby causing switches or links to become overloaded. Thus flow control is an end to an end issue, while congestion control is concerned with how hosts and networks interact.