Context parameters can not be anything other tham String. If we want to set init parameter to be sth else, we need to add a listener which would convert the String value to the desired value.
coz we can not put the code in Servlet as the servlet would have got the parameter value as String only by then.
This is done by implementing "ServletContextListener" interface which has two methods - contextInitialized(ServletContextEvent) and contextDestroyed(ServletContextEvent)
Difference between Attribute and Parameter
Attribute :
1. Type : Application / context , Request , Session
2. Method to set : setAttribute(String name , Object value)
3. Return type : Object
4. Method to get : getAttribute(String name)
Parameter :
1. Type : Application /context , Request , Servlet init parameters
2. Method : These can be set only in Deployment descriptor (web.xml)
3 . Return type : String
4. Method to get : getInitParameter(String name)
Context scope isnt thread safe. We can make them thread safe by using : synchronized(getServletContext())
Session persists across multiple requests from same client.
Its also not thread safe. We can makr it thread safe as we did to Context : synchronized(session)
Only requesr attributes and local variables are thread safe. Instance variables arnt.
we generally do not declare non final instance variables in Servlets.
We also have a "SingleThreadModel" interface, which can be used to make servlet thread safe. But this interface should better not be used as it effects performance a lot.
RequestDispatcher has two methods : forward(request , response) and include(request , response)
include() sends the request to do sth and it then comes back to the sender.
Difference b/w RequestDispatcher from context and from request
In the one from context, you can not specify relative path. u must specify absolute path.
Welcome Message
Hi, welcome to my website. This is a place where you can get all the questions, puzzles, algorithms asked in interviews and their solutions. Feel free to contact me if you have any queries / suggestions and please leave your valuable comments.. Thanks for visiting -Pragya.
Top Navigation Menu
October 27, 2009
October 25, 2009
Servlets and JSPs
GET requests can be bookmarked but POST can not be.
GET is idempotent(Its used for getting things from the server, its not supposed to change anything ) , POST is not
addHeader() and setHeader() methods of response : Both will add a header and value to response if the header is not already present. The difference between these two occurs when the header is already there.
setHeader() overwrites the existing value
addHeader() adds an additional value
We can not do a send redirect after writing to the response. If we try to do so, it will throw an llegal state exception
Difference b/w redirect and a request dispatch : redirect makes the client do the work and sendRedirect makes sth on the server do the work.
we can not use Servlet init param unless the servlet is initialised.
sendredirect is called on response and request dispatcher is called on request
response.sendRedirect() and request.getRequestDispatcher() and then dispatcher.forward()
Also, in case of request dispatcher, the URL is not changed, so the user does not get to know about that.
GET is idempotent(Its used for getting things from the server, its not supposed to change anything ) , POST is not
addHeader() and setHeader() methods of response : Both will add a header and value to response if the header is not already present. The difference between these two occurs when the header is already there.
setHeader() overwrites the existing value
addHeader() adds an additional value
We can not do a send redirect after writing to the response. If we try to do so, it will throw an llegal state exception
Difference b/w redirect and a request dispatch : redirect makes the client do the work and sendRedirect makes sth on the server do the work.
we can not use Servlet init param unless the servlet is initialised.
sendredirect is called on response and request dispatcher is called on request
response.sendRedirect() and request.getRequestDispatcher() and then dispatcher.forward()
Also, in case of request dispatcher, the URL is not changed, so the user does not get to know about that.
Hibernate related
Advantages :
1. Productivity : Persistence related code is very tough to write. Hibernate eliminates much of the grunt work.So we can utilize the effort we could have used in writing hand coded persistence logic.
2. Maintainability : In hand coded persistence, change in one of the object or relationship domain leads to change in other also. But hibernate provides us a buffer between the two midels, insultaing each model from minor changes in the other. Otherwise, most of the times, change needs to be made at the java side, which is thus prevented by using hibernate.
3. Performance : We can also optimize the existing hibernate code as per our requirements.Also, since hibernate provides automated persistence, it increases developer performance.
4. Vendor Independence : An ORM abstracts your application away from the underlying SQL databases and SQL dialect. If the tool supports a number of different databases, then this confers a certain level of portability on your application.
Persistence allows an object to outlice the process that created it. The state of the object may be stored to disk and an object with same state can be recreated.
problems with ORM that hibernate addresses:
1. Problem of Granularity : (Fine grained and coarse grained objects.)
2. Problem of identity : In java , identity can be defined by equals method or memory location and in DB, it is represented by primary key. Therefore,Identity should be something that should have no meaning to user.
3. Problem of association
4. Problem of subtyping
5. P of Object graph navigation.
for details refer page 10-15 chapter 1 of hibernate in action.
1. Productivity : Persistence related code is very tough to write. Hibernate eliminates much of the grunt work.So we can utilize the effort we could have used in writing hand coded persistence logic.
2. Maintainability : In hand coded persistence, change in one of the object or relationship domain leads to change in other also. But hibernate provides us a buffer between the two midels, insultaing each model from minor changes in the other. Otherwise, most of the times, change needs to be made at the java side, which is thus prevented by using hibernate.
3. Performance : We can also optimize the existing hibernate code as per our requirements.Also, since hibernate provides automated persistence, it increases developer performance.
4. Vendor Independence : An ORM abstracts your application away from the underlying SQL databases and SQL dialect. If the tool supports a number of different databases, then this confers a certain level of portability on your application.
Persistence allows an object to outlice the process that created it. The state of the object may be stored to disk and an object with same state can be recreated.
problems with ORM that hibernate addresses:
1. Problem of Granularity : (Fine grained and coarse grained objects.)
2. Problem of identity : In java , identity can be defined by equals method or memory location and in DB, it is represented by primary key. Therefore,Identity should be something that should have no meaning to user.
3. Problem of association
4. Problem of subtyping
5. P of Object graph navigation.
for details refer page 10-15 chapter 1 of hibernate in action.
Labels:
Hibernate
Difference : Web Server and Application Server
A fully compliant Application Server must have both a Web Container and an EJB Container (plus other things including a JNDI and JMS implementation). Tomcat is just a web container. It is still compliant with portions of J2EE spec that address the web ocntainer.
JBoss is an application server
JBoss is an application server
October 24, 2009
Fine Grained Vs Coarse Grained
Coarse-grained: A few ojects hold a lot of related data. Example: A single "Account" object holds the customer name, address, account balance, opening date, last change date, etc.
Fine-grained: More objects each holding less data. Example: An Account object holds balance, a Customer object holds name and address, a AccountOpenings object holds opening date, etc. There are relationships defined between these objects.
Reference : http://www.theserverside.com/discussions/thread.tss?thread_id=5164
Fine-grained: More objects each holding less data. Example: An Account object holds balance, a Customer object holds name and address, a AccountOpenings object holds opening date, etc. There are relationships defined between these objects.
Reference : http://www.theserverside.com/discussions/thread.tss?thread_id=5164
Labels:
interview
October 11, 2009
Computer Networking questions
1. What do you need to know about addresses?
You probably know what an IP address is: a number that identifies that device on the network. But what else do you need to know? IP addresses are made up of 32 bits (IPv4 addresses, that is). We normally think of an IP address as something like 1.1.1.1, but really this can be translated into eight binary bits (see Binary-to-Decimal Conversion for more information). Each set of binary bits can represent only the numbers zero through 255. That is why your IP addresses can range only from 0.0.0.0 to 255.255.255.255.
By the way, the IP address 255.255.255.255 is called the "all ones" network because in binary it is represented by 32 numeral ones (1s). The all ones address is used to send a packet to all devices on all networks (as long as it isn't stopped by a router first).
Traditionally, IP addresses were broken up into classes, but those classes aren't used much any more unless you are taking a certification exam. We will learn more about classes below.
Most importantly, IP addresses must be unique on your network. If two devices have the exact same IP address, you have an IP address conflict. When that happens, either device or both devices will not work on the network. Commonly, DHCP is used to dynamically allocate IP addresses in hopes of preventing address duplication and easing the administrative burden of static IP addressing.
Q : What is a subnet mask?
A subnet mask is what tells your computer (or other network device) what portion of the IP address is used to represent your network and what part is used to represent hosts (other computers) on your network. For example, if you have an IP address of 1.1.1.1 and a subnet mask of 255.255.255.0, the 255s mask off the first three 1s. If you did the logical "AND" (the calculation your computer does -- see Binary-to-Decimal Conversion for more information), you would find out that the network ID for this network is 1.1.1.0. Where the 0 is located, you could fill in hosts numbered 1 to 254. For example, the first host on your network is 1.1.1.1 and the last host is 1.1.1.254.
Of special note when looking at the number of hosts in a network is this: The first IP address in a network is the network address and the last IP address is always the broadcast address. That's why I couldn't use IP address 1.1.1.0 and IP address 1.1.1.255. These are special, reserved addresses, but some computers will allow you to use the network address as a real computer address.
"Subnetting" is breaking up a single network into smaller networks. To do this, you add more bits (more numbers) to the subnet mask. Traditionally, we are used to seeing subnet masks that look like 255.0.0.0, 255.255.0.0, or 255.255.255.0. However, a subnet mask might also look like 255.255.128.0 or 255.255.255.224. In both of these cases, it is obvious that the network has been subnetted to break a single network into smaller networks.
3. What is the difference between "classful" and "classless" IP addressing?
When the concept of IP addressing was first thought up, it was decided that IP addresses would be put into classes. These classes are:
ClassIP address rangeDefault subnet mask
A 1.0.0.0 to 127.255.255.255 255.0.0.0
B 128.0.0.0 to 191.255.255.255 255.255.0.0
C 192.0.0.0 to 223.255.255.255 255.255.255.0
Today, these default subnet masks aren't much used except as a point of reference and trivia. For example, if I said that your IP address was 192.168.1.1 but didn't tell you the subnet mask, it would be safe to assume that your subnet mask is 255.255.255.0 because that IP address falls into the Class C range. This is also important when you take some certification tests.
In real life, an IP address today could have any legal subnet mask. For example, you may have an IP address of 1.1.1.1 with a subnet mask of 255.255.255.240. Or you may have an IP address of 192.192.192.192 with a subnet mask of 255.0.0.0. Sometimes, people will say things like "I need an entire Class C block of addresses." This just means that they want 254 contiguous and usable IP addresses.
The term "classful" means that the IP address or software is assuming that IP addresses fall into these classes and uses the default subnet mask shown. If a routing protocol, like RIP, is classful, it has trouble with the IP addresses that don't use the default subnet masks.
On the other hand, a "classless" routing protocol, like RIP version 2, doesn't assume that IP addresses have their default subnet masks. Today, you should assume that all network devices are classless unless you find that they are not (like routing protocols RIP or IGRP, or a very old computer operating system).
4. What is a default gateway?
Contrary to popular belief, a default gateway is not a required piece of IP address configuration on any computer. However, if you want to access devices outside of your local network (such as devices on the Internet), a default gateway is required.
A default gateway is where a computer sends requests to IP addresses that are not on its local network. How does the computer know what is and what is not on its local network? As discussed above, the subnet mask is what the computer uses to know what is and what is not on its local network. Say, for example, your IP address is 1.1.1.1 and your subnet mask is 255.255.255.0, and you make a Web request to 1.1.2.1. Because of your subnet mask, your local area network is the 1.1.1.0 network. Meaning anything that is 1.1.1.1 through 254 is on your local network. Because you are requesting 1.1.2.1, which is not on your local network, that packet would be sent to your default gateway.
5. What are private IP addresses?
The private IP address space is defined by RFC1918. In this RFC, it says that no public (take that as "no Internet") devices will use or recognize the following IP addresses:
Your IP address may be the same on your PC as someone else's if you have a private IP address. These ranges of IP addresses are available for anyone to use on their own internal (private) network. There is no need to keep them unique. I can have IP address 192.168.1.1 on my home network and so can everyone else in the world! When I go to make a request to the Internet, however, that private IP address must be converted into a public IP address or else the Internet router I make the request to will just throw my request away (because I have a private IP address). Network Address Translation (NAT) is what performs this public-to-private translation (see RFC1631 and RFC2663 for more information on NAT).
Private IP addresses are there to reduce the need for more public IP addresses. An unintentional consequence is that they provide a tiny bit of security.
So, if I am trying to FTP to your computer on the Internet and you tell me that your IP address is 192.168.3.3, I will tell you "No, I need your public IP address, not your private IP address."
Link : http://searchnetworking.techtarget.com/tip/0,289483,sid7_gci1220092,00.html
You probably know what an IP address is: a number that identifies that device on the network. But what else do you need to know? IP addresses are made up of 32 bits (IPv4 addresses, that is). We normally think of an IP address as something like 1.1.1.1, but really this can be translated into eight binary bits (see Binary-to-Decimal Conversion for more information). Each set of binary bits can represent only the numbers zero through 255. That is why your IP addresses can range only from 0.0.0.0 to 255.255.255.255.
By the way, the IP address 255.255.255.255 is called the "all ones" network because in binary it is represented by 32 numeral ones (1s). The all ones address is used to send a packet to all devices on all networks (as long as it isn't stopped by a router first).
Traditionally, IP addresses were broken up into classes, but those classes aren't used much any more unless you are taking a certification exam. We will learn more about classes below.
Most importantly, IP addresses must be unique on your network. If two devices have the exact same IP address, you have an IP address conflict. When that happens, either device or both devices will not work on the network. Commonly, DHCP is used to dynamically allocate IP addresses in hopes of preventing address duplication and easing the administrative burden of static IP addressing.
Q : What is a subnet mask?
A subnet mask is what tells your computer (or other network device) what portion of the IP address is used to represent your network and what part is used to represent hosts (other computers) on your network. For example, if you have an IP address of 1.1.1.1 and a subnet mask of 255.255.255.0, the 255s mask off the first three 1s. If you did the logical "AND" (the calculation your computer does -- see Binary-to-Decimal Conversion for more information), you would find out that the network ID for this network is 1.1.1.0. Where the 0 is located, you could fill in hosts numbered 1 to 254. For example, the first host on your network is 1.1.1.1 and the last host is 1.1.1.254.
Of special note when looking at the number of hosts in a network is this: The first IP address in a network is the network address and the last IP address is always the broadcast address. That's why I couldn't use IP address 1.1.1.0 and IP address 1.1.1.255. These are special, reserved addresses, but some computers will allow you to use the network address as a real computer address.
"Subnetting" is breaking up a single network into smaller networks. To do this, you add more bits (more numbers) to the subnet mask. Traditionally, we are used to seeing subnet masks that look like 255.0.0.0, 255.255.0.0, or 255.255.255.0. However, a subnet mask might also look like 255.255.128.0 or 255.255.255.224. In both of these cases, it is obvious that the network has been subnetted to break a single network into smaller networks.
3. What is the difference between "classful" and "classless" IP addressing?
When the concept of IP addressing was first thought up, it was decided that IP addresses would be put into classes. These classes are:
ClassIP address rangeDefault subnet mask
A 1.0.0.0 to 127.255.255.255 255.0.0.0
B 128.0.0.0 to 191.255.255.255 255.255.0.0
C 192.0.0.0 to 223.255.255.255 255.255.255.0
Today, these default subnet masks aren't much used except as a point of reference and trivia. For example, if I said that your IP address was 192.168.1.1 but didn't tell you the subnet mask, it would be safe to assume that your subnet mask is 255.255.255.0 because that IP address falls into the Class C range. This is also important when you take some certification tests.
In real life, an IP address today could have any legal subnet mask. For example, you may have an IP address of 1.1.1.1 with a subnet mask of 255.255.255.240. Or you may have an IP address of 192.192.192.192 with a subnet mask of 255.0.0.0. Sometimes, people will say things like "I need an entire Class C block of addresses." This just means that they want 254 contiguous and usable IP addresses.
The term "classful" means that the IP address or software is assuming that IP addresses fall into these classes and uses the default subnet mask shown. If a routing protocol, like RIP, is classful, it has trouble with the IP addresses that don't use the default subnet masks.
On the other hand, a "classless" routing protocol, like RIP version 2, doesn't assume that IP addresses have their default subnet masks. Today, you should assume that all network devices are classless unless you find that they are not (like routing protocols RIP or IGRP, or a very old computer operating system).
4. What is a default gateway?
Contrary to popular belief, a default gateway is not a required piece of IP address configuration on any computer. However, if you want to access devices outside of your local network (such as devices on the Internet), a default gateway is required.
A default gateway is where a computer sends requests to IP addresses that are not on its local network. How does the computer know what is and what is not on its local network? As discussed above, the subnet mask is what the computer uses to know what is and what is not on its local network. Say, for example, your IP address is 1.1.1.1 and your subnet mask is 255.255.255.0, and you make a Web request to 1.1.2.1. Because of your subnet mask, your local area network is the 1.1.1.0 network. Meaning anything that is 1.1.1.1 through 254 is on your local network. Because you are requesting 1.1.2.1, which is not on your local network, that packet would be sent to your default gateway.
5. What are private IP addresses?
The private IP address space is defined by RFC1918. In this RFC, it says that no public (take that as "no Internet") devices will use or recognize the following IP addresses:
Your IP address may be the same on your PC as someone else's if you have a private IP address. These ranges of IP addresses are available for anyone to use on their own internal (private) network. There is no need to keep them unique. I can have IP address 192.168.1.1 on my home network and so can everyone else in the world! When I go to make a request to the Internet, however, that private IP address must be converted into a public IP address or else the Internet router I make the request to will just throw my request away (because I have a private IP address). Network Address Translation (NAT) is what performs this public-to-private translation (see RFC1631 and RFC2663 for more information on NAT).
Private IP addresses are there to reduce the need for more public IP addresses. An unintentional consequence is that they provide a tiny bit of security.
So, if I am trying to FTP to your computer on the Internet and you tell me that your IP address is 192.168.3.3, I will tell you "No, I need your public IP address, not your private IP address."
Link : http://searchnetworking.techtarget.com/tip/0,289483,sid7_gci1220092,00.html
Labels:
Networking
October 10, 2009
Why Strings are immutable
The basic reason is that we use String pool for String objects.So if we have a number of objects that have same value, all the reference variables would be pointing to the same value in the pool. So if string were nt immutable and somebody chaged that value, the value of all the objects pointing to that object would change, which is undesired.
You might wonder why Strings are immutable in first place. There are two very compelling reasons for it:
1. Immutable basic types makes things easier. If you pass a String to a function you can be sure that its value won't change.
2. Security. With mutable Strings one could bypass security checks by changing the value right after the check. (Same thing as the first point, really.)
Detailed Description :
http://kaioa.com/node/59
You might wonder why Strings are immutable in first place. There are two very compelling reasons for it:
1. Immutable basic types makes things easier. If you pass a String to a function you can be sure that its value won't change.
2. Security. With mutable Strings one could bypass security checks by changing the value right after the check. (Same thing as the first point, really.)
Detailed Description :
http://kaioa.com/node/59
September 14, 2009
Belzabar Questions (Flash and Java)
Flash (28 questions remain)
You can set the size, frame rate, and background color in:
Please select an answer
Document properties
Stage
Property inspector
Action panel
Timeline
Employment Assessment
Flash (27 questions remain)
Which of the following is not an Event Handler?
Please select an answer
load
enterframe
frameload
mousedown
Flash (26 questions remain)
You have just added a Motion Guide layer to your movie and have drawn a path in it. For an object's motion to follow a path, what must be attached to the path?
Please select an answer
The Streaming Graph
The bottom-most point of the object on every frame in the tween
The registration point of the symbol in the starting and ending keyframe
A second instance of the moving object in that frame.
There should not be anything attached to the path that would cause a motion error.
ployment Assessment
Flash (25 questions remain)
Which one of the following statements regarding tweening is true?
Please select an answer
Two or more tweened symbols should be placed on the same layer.
You cannot tween color changes, only the motion of an object.
An error occurs if you try to motion tween an instance of an object.
Alpha Transparency is controlled by using the Fade option.
Orientation, Rotation, and Easing are controlled in the Properties Panel.
Flash (24 questions remain)
Using the startDrag() action, a movie clip can be made draggable until when?
Please select an answer
Until the movie clip is dragged off of the visible portion of the stage
Until the stopDrag() action is used or another movie clip is made draggable
Until the movie clip is dragged over an object on a locked layer
Until the Constrain to Rectangle option is set
Until the mouse is released or double-clicked
Flash (23 questions remain)
Which one of the following commands converts a raster image into a vector image?
Please select an answer
The Color Effect command
The Scale and Rotate command
The Trace Bitmap command
The Optimize Shape command
The Add Shape Hint command
Flash (22 questions remain)
Which ActionScript method loads an MP3 file and plays the sound while downloading?
Please select an answer
loadSound("audio/mysounds.mp3",true);
attachSound("audio/mysounds.mp3");
loadSound("audio/mysounds.mp3",false);
loadMovie("audio/mysounds.mp3");
loadMovie("audio/mysounds.mp3",true);
Flash (21 questions remain)
On your main timeline, you have a MovieClip instance moving across the stage over a period of 100 frames. You would like to use the Output Window to view the pixel location of the instance for each frame of animation.
Which one of the following ActionScript functions outputs text to the Output Window?
Please select an answer
Debug.print()
output()
trace()
show()
System.write()
Flash (20 questions remain)
To create a new, blank movieclip on stage, which one of the following ActionScript commands do you use?
Please select an answer
createEmptyMovieClip("myNewClip",100);
attachMovie(null,"myNewClip",100);
duplicateMovieClip("myNewClip",100);
myNewClip.loadMovie(null);
myNewClip = new MovieClip();
Flash (19 questions remain)
What does this sample code represent?
if (myVar == ("Gordon"||"Vicki"||"Chuck")){
_root[myVar].gotoAndPlay(1);
}else{
_root.welcome.gotoAndPlay(1);
}
Please select an answer
function that detects the client's username information and moves the playhead of the main timeline depending on the value
A conditional action that checks the value of myVar and plays one of several movie clips depending on the value
A conditional action that moves the playhead of the main timeline to the Frame Label specified by the myVar variable
An array that sets the value of the myVar variable depending on the current frame
An ActionScript that causes an error because there are no valid targets specified
Java II (18 questions remain)
If you compile and execute an application with the following code in its main() method:
String s = new String( �Computer� );
if( s == �Computer� )
System.out.println( �Equal A� );
if( s.equals( �Computer� ) )
System.out.println( �Equal B� );
Please select an answer
It will not compile because the String class does not support the = = operator.
It will compile and run, but nothing is printed.
�Equal A� is the only thing that is printed.
�Equal B� is the only thing that is printed.
Both �Equal A� and �Equal B� are printed.
Java II (17 questions remain)
Consider the two statements:
1. boolean passingScore = false && grade == 70;
2. boolean passingScore = false & grade == 70;
The expression : grade == 70, is evaluated:
Please select an answer
in both 1 and 2
in neither 1 nor 2
in 1 but not 2
in 2 but not 1
invalid because false should be FALSE
Java II (16 questions remain)
Given the variable declarations below:
byte myByte;
int myInt;
long myLong;
char myChar;
float myFloat;
double myDouble;
Which one of the following assignments would need an explicit cast?
Please select an answer
myInt= myByte;
myInt= myLong;
myByte= 3;
myInt= myChar;
myFloat= 3;
Java II (15 questions remain)
Consider the code below:
arr[0] = new int[4];
arr[1] = new int[3];
arr[2] = new int[2];
arr[3] = new int[1];
for( int n = 0; n < 4; n++ ) System.out.println( /* what goes here? */ );
Which statement below, when inserted as the
body of the for loop, would print the number of values in each row?
Please select an answer
arr[n].length();
arr.size;
arr.size-1;
arr[n][size];
arr[n].length;
Java II (14 questions remain)
Given following code with line numbers:
31. // some code here
32. try {
33. // some code here
34. } catch (SomeException se) {
35. // some code here
36. } finalize {
37. // some code here
38. }
Under which circumstances will the code on line 37 be executed?
(Choose Correct Answer.)
Please select an answer
The instance gets garbage collected.
The code on line 33 throws an exception.
Compilation error
The code on line 31 throws an exception.
Will never get executed
Java II (13 questions remain)
Which Man class properly represents the relationship “Man has a best
friend who is a Dog�?
Please select an answer
class Man extends Dog { }
class Man implements Dog { }
class Man { private BestFriend dog; }
class Man { private Dog bestFriend; }
class Man { private Dog }
class Man { private BestFriend }
Java II (12 questions remain)
Which about the three java.lang classes String, StringBuilder, and StringBuffer is true
Please select an answer
All three classes have a length property.
Objects of type StringBuffer are thread-safe.
All three classes have overloaded append() methods.
The "+" is an overloaded operator for all three classes.
According to the API, StringBuffer will be faster than StringBuilder under most
The value of an instance of any of these three types can be modified through various methods in the API.
Java II (11 questions remain)
Which statement is true about comparing two instances of the same class, given that the equals() and hashCode() methods have been properly overridden? (Choose all that apply.)
Please select an answer
If the equals() method returns true, the hashCode() comparison == might return false.
If the equals() method returns false, the hashCode() comparison == might return true.
If the hashCode() comparison == returns true, the equals() method must return true.
If the hashCode() comparison != returns true, the equals() method might return true.
All of the above
Java II (10 questions remain)
Which collection class allows you to grow or shrink its size and provides indexed access to its elements, but whose methods are not synchronized?
Please select an answer
java.util.HashSet
java.util.LinkedHashSet
java.util.List
java.util.ArrayList
java.util.Vector
java.util.PriorityQueue
Java II (9 questions remain)
Given this method in a class:
21. public String toString() {
22. StringBuffer buffer = new StringBuffer();
23. buffer.append(’<’);
24. buffer.append(this.name);
25. buffer.append(’>’);
26. return buffer.toString();
27. }
Which is true?
Please select an answer
This code is NOT thread-safe.
The programmer can replace StringBuffer with StringBuilder with no other changes.
This code will perform well and converting the code to use StringBuilder will not enhance the performance.
This code will perform poorly. For better performance, the code should be rewritten: return “<“+ this.name + “>�;
Java II (8 questions remain)
Given 1. public class Threads3 implements Runnable {
2. public void run() {
3. );
4. }
5. public static void main(String[] args) {
6. Thread t = new Thread(new Threads3());
7. t.run();
8. t.run();
9. t.start();
10. }
11. }
What is the result?
Please select an answer
Compilation fails.
An exception is thrown at runtime.
The code executes and prints “running�.
The code executes and prints “runningrunning�.
The code executes and prints “runningrunningrunningâ€
Java II (7 questions remain)
Which is true?
Please select an answer
An encapsulated, public class promotes re-use.
Classes that share the same interface are always tightly encapsulated.
An encapsulated class allows subclasses to overload methods, but does NOT allow overriding methods.
All of the above
Java II (6 questions remain)
Which three occur during JSP page translation?
Please select an answer
JSP init method is called.
JSP page implementation class is created and compiled.
JSP page initializeMe() is called
JSP page is destroyed.
associated file tags are validated for syntax.
Java II (5 questions remain)
JSP page developer wants to add a comment to final output in browser.Which comment should be used:
Please select an answer
<%// this is a comment%>
<%-- this is a comment--%>
<%/* this is a comment*/%>
Java II (4 questions remain)
Request Dispatcher can be obtained from which two objects:
Please select an answer
ServletConfig
HttpServletRequest
HttpServletResponse
Session
Java II (3 questions remain)
Which class does not need ac commection to be alive
Please select an answer
RowSet
ResultSet
All of the above
None of above
Java II (2 questions remain)
which is correct web application deployment descriptor element for defining servlet initializing parameter
Please select an answer
" "
""
""
""
Java II (1 questions remain)
Given:
10. interface A { void x(); }
11. class B implements Ab { public void x() { } public voidy() { } }
12. class C extends B { public void x() {} }
And:
20. java.util.List list = new java.util.ArrayList();
21. list.add(new B());
22. list.add(new C());
23. for (Ab a:list) {
24. a.x();
25. a.y();;
26. }
What is the result?
Please select an answer
The code runs with no output.
An exception is thrown at runtime.
Compilation fails because of an error in line 20.
Compilation fails because of an error in line 21.
Compilation fails because of an error in line 23.
Compilation fails because of an error in line 25.
You can set the size, frame rate, and background color in:
Please select an answer
Document properties
Stage
Property inspector
Action panel
Timeline
Employment Assessment
Flash (27 questions remain)
Which of the following is not an Event Handler?
Please select an answer
load
enterframe
frameload
mousedown
Flash (26 questions remain)
You have just added a Motion Guide layer to your movie and have drawn a path in it. For an object's motion to follow a path, what must be attached to the path?
Please select an answer
The Streaming Graph
The bottom-most point of the object on every frame in the tween
The registration point of the symbol in the starting and ending keyframe
A second instance of the moving object in that frame.
There should not be anything attached to the path that would cause a motion error.
ployment Assessment
Flash (25 questions remain)
Which one of the following statements regarding tweening is true?
Please select an answer
Two or more tweened symbols should be placed on the same layer.
You cannot tween color changes, only the motion of an object.
An error occurs if you try to motion tween an instance of an object.
Alpha Transparency is controlled by using the Fade option.
Orientation, Rotation, and Easing are controlled in the Properties Panel.
Flash (24 questions remain)
Using the startDrag() action, a movie clip can be made draggable until when?
Please select an answer
Until the movie clip is dragged off of the visible portion of the stage
Until the stopDrag() action is used or another movie clip is made draggable
Until the movie clip is dragged over an object on a locked layer
Until the Constrain to Rectangle option is set
Until the mouse is released or double-clicked
Flash (23 questions remain)
Which one of the following commands converts a raster image into a vector image?
Please select an answer
The Color Effect command
The Scale and Rotate command
The Trace Bitmap command
The Optimize Shape command
The Add Shape Hint command
Flash (22 questions remain)
Which ActionScript method loads an MP3 file and plays the sound while downloading?
Please select an answer
loadSound("audio/mysounds.mp3",true);
attachSound("audio/mysounds.mp3");
loadSound("audio/mysounds.mp3",false);
loadMovie("audio/mysounds.mp3");
loadMovie("audio/mysounds.mp3",true);
Flash (21 questions remain)
On your main timeline, you have a MovieClip instance moving across the stage over a period of 100 frames. You would like to use the Output Window to view the pixel location of the instance for each frame of animation.
Which one of the following ActionScript functions outputs text to the Output Window?
Please select an answer
Debug.print()
output()
trace()
show()
System.write()
Flash (20 questions remain)
To create a new, blank movieclip on stage, which one of the following ActionScript commands do you use?
Please select an answer
createEmptyMovieClip("myNewClip",100);
attachMovie(null,"myNewClip",100);
duplicateMovieClip("myNewClip",100);
myNewClip.loadMovie(null);
myNewClip = new MovieClip();
Flash (19 questions remain)
What does this sample code represent?
if (myVar == ("Gordon"||"Vicki"||"Chuck")){
_root[myVar].gotoAndPlay(1);
}else{
_root.welcome.gotoAndPlay(1);
}
Please select an answer
function that detects the client's username information and moves the playhead of the main timeline depending on the value
A conditional action that checks the value of myVar and plays one of several movie clips depending on the value
A conditional action that moves the playhead of the main timeline to the Frame Label specified by the myVar variable
An array that sets the value of the myVar variable depending on the current frame
An ActionScript that causes an error because there are no valid targets specified
Java II (18 questions remain)
If you compile and execute an application with the following code in its main() method:
String s = new String( �Computer� );
if( s == �Computer� )
System.out.println( �Equal A� );
if( s.equals( �Computer� ) )
System.out.println( �Equal B� );
Please select an answer
It will not compile because the String class does not support the = = operator.
It will compile and run, but nothing is printed.
�Equal A� is the only thing that is printed.
�Equal B� is the only thing that is printed.
Both �Equal A� and �Equal B� are printed.
Java II (17 questions remain)
Consider the two statements:
1. boolean passingScore = false && grade == 70;
2. boolean passingScore = false & grade == 70;
The expression : grade == 70, is evaluated:
Please select an answer
in both 1 and 2
in neither 1 nor 2
in 1 but not 2
in 2 but not 1
invalid because false should be FALSE
Java II (16 questions remain)
Given the variable declarations below:
byte myByte;
int myInt;
long myLong;
char myChar;
float myFloat;
double myDouble;
Which one of the following assignments would need an explicit cast?
Please select an answer
myInt= myByte;
myInt= myLong;
myByte= 3;
myInt= myChar;
myFloat= 3;
Java II (15 questions remain)
Consider the code below:
arr[0] = new int[4];
arr[1] = new int[3];
arr[2] = new int[2];
arr[3] = new int[1];
for( int n = 0; n < 4; n++ ) System.out.println( /* what goes here? */ );
Which statement below, when inserted as the
body of the for loop, would print the number of values in each row?
Please select an answer
arr[n].length();
arr.size;
arr.size-1;
arr[n][size];
arr[n].length;
Java II (14 questions remain)
Given following code with line numbers:
31. // some code here
32. try {
33. // some code here
34. } catch (SomeException se) {
35. // some code here
36. } finalize {
37. // some code here
38. }
Under which circumstances will the code on line 37 be executed?
(Choose Correct Answer.)
Please select an answer
The instance gets garbage collected.
The code on line 33 throws an exception.
Compilation error
The code on line 31 throws an exception.
Will never get executed
Java II (13 questions remain)
Which Man class properly represents the relationship “Man has a best
friend who is a Dog�?
Please select an answer
class Man extends Dog { }
class Man implements Dog { }
class Man { private BestFriend dog; }
class Man { private Dog bestFriend; }
class Man { private Dog
class Man { private BestFriend
Java II (12 questions remain)
Which about the three java.lang classes String, StringBuilder, and StringBuffer is true
Please select an answer
All three classes have a length property.
Objects of type StringBuffer are thread-safe.
All three classes have overloaded append() methods.
The "+" is an overloaded operator for all three classes.
According to the API, StringBuffer will be faster than StringBuilder under most
The value of an instance of any of these three types can be modified through various methods in the API.
Java II (11 questions remain)
Which statement is true about comparing two instances of the same class, given that the equals() and hashCode() methods have been properly overridden? (Choose all that apply.)
Please select an answer
If the equals() method returns true, the hashCode() comparison == might return false.
If the equals() method returns false, the hashCode() comparison == might return true.
If the hashCode() comparison == returns true, the equals() method must return true.
If the hashCode() comparison != returns true, the equals() method might return true.
All of the above
Java II (10 questions remain)
Which collection class allows you to grow or shrink its size and provides indexed access to its elements, but whose methods are not synchronized?
Please select an answer
java.util.HashSet
java.util.LinkedHashSet
java.util.List
java.util.ArrayList
java.util.Vector
java.util.PriorityQueue
Java II (9 questions remain)
Given this method in a class:
21. public String toString() {
22. StringBuffer buffer = new StringBuffer();
23. buffer.append(’<’);
24. buffer.append(this.name);
25. buffer.append(’>’);
26. return buffer.toString();
27. }
Which is true?
Please select an answer
This code is NOT thread-safe.
The programmer can replace StringBuffer with StringBuilder with no other changes.
This code will perform well and converting the code to use StringBuilder will not enhance the performance.
This code will perform poorly. For better performance, the code should be rewritten: return “<“+ this.name + “>�;
Java II (8 questions remain)
Given 1. public class Threads3 implements Runnable {
2. public void run() {
3. );
4. }
5. public static void main(String[] args) {
6. Thread t = new Thread(new Threads3());
7. t.run();
8. t.run();
9. t.start();
10. }
11. }
What is the result?
Please select an answer
Compilation fails.
An exception is thrown at runtime.
The code executes and prints “running�.
The code executes and prints “runningrunning�.
The code executes and prints “runningrunningrunningâ€
Java II (7 questions remain)
Which is true?
Please select an answer
An encapsulated, public class promotes re-use.
Classes that share the same interface are always tightly encapsulated.
An encapsulated class allows subclasses to overload methods, but does NOT allow overriding methods.
All of the above
Java II (6 questions remain)
Which three occur during JSP page translation?
Please select an answer
JSP init method is called.
JSP page implementation class is created and compiled.
JSP page initializeMe() is called
JSP page is destroyed.
associated file tags are validated for syntax.
Java II (5 questions remain)
JSP page developer wants to add a comment to final output in browser.Which comment should be used:
Please select an answer
<%// this is a comment%>
<%-- this is a comment--%>
<%/* this is a comment*/%>
Java II (4 questions remain)
Request Dispatcher can be obtained from which two objects:
Please select an answer
ServletConfig
HttpServletRequest
HttpServletResponse
Session
Java II (3 questions remain)
Which class does not need ac commection to be alive
Please select an answer
RowSet
ResultSet
All of the above
None of above
Java II (2 questions remain)
which is correct web application deployment descriptor element for defining servlet initializing parameter
Please select an answer
"
"
"
"
Java II (1 questions remain)
Given:
10. interface A { void x(); }
11. class B implements Ab { public void x() { } public voidy() { } }
12. class C extends B { public void x() {} }
And:
20. java.util.List
21. list.add(new B());
22. list.add(new C());
23. for (Ab a:list) {
24. a.x();
25. a.y();;
26. }
What is the result?
Please select an answer
The code runs with no output.
An exception is thrown at runtime.
Compilation fails because of an error in line 20.
Compilation fails because of an error in line 21.
Compilation fails because of an error in line 23.
Compilation fails because of an error in line 25.
Subscribe to:
Posts (Atom)