Java variables act as object or not?
How a Java variable would act depends on the variable's data type. Variables of the primitive data types like int, char, float etc would not act as objects. But apart from them, all other data types would act as Objects. Almost all data types would extend from java.lang.Object and would behave as objects.
What is a constructor and what are its special properties?
A constructor creates an Object of the class that it is in by initializing all the instance variables and creating a place in memory to hold the Object. It is always used with the keyword new and then the Class name.
For instance, new String(); constructs a new String object.
Sometimes in a few classes you may have to initialize a few of the variables to values apart from their predefined data type specific values. If java initializes variables it would default them to their variable type specific values. For example you may want to initialize an integer variable to 10 or 20 based on a certain condition, when your class is created. In such a case you cannot hard code the value during variable declaration. such kind of code can be placed inside the constructor so that the initialization would happen when the class is instantiated.
Properties:
1. You need not code them explicitly. Java will automatically place a default constructor
2. You can pass arguments to the constructor
3. They can return only an object of type of that class
4. They can be made private
5. They would be executed always (Everytime a class is instantiated)
Can the remainder or modulus operator be used with floating point operands?
Very well YES
public class ModTest {
/**
* @param args
*/
public static void main(String[] args) {
System.out.println(10.5%2);
}
}
Output of the above program is: 0.5
Which application server support java platform?
All major servers like Weblogic, Webspher, Tomcat support Java Platform
What is coping with complexity in oops?
The size and complexity of a small program is small and simple. Whereas, the size and complexity of a large application program is large and hard. The complexity in dealing with the problems to build a large application depends on the 'composition' and 'abstraction' mechanisms.
How do you create an instance of inner class outside outer class in java?
is given below
package com.test.reflection;
public class Outer
{
public static class Nested
{
public void printMesg(String body)
{
System.out.println(body);
}
}
public class Inner
{
public void printMesg(String body)
{
System.out.println(body);
}
}
}
package com.test.reflection;
import com.test.reflection.Outer.
Nested;
public class AnotherClass {
public static void main(String[] args){
try {
//Bar b=(Bar) Foo.Bar.class.getConstructors()[0].newInstance(new Foo());
//b.printMesg("hello");
Nested nested=new Nested();
nested.printMesg("nested class");
Outer.Inner inner=new Outer().new Inner();
inner.printMesg("Inner class");
//b1.printMesg("static");
} catch (IllegalArgumentException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (SecurityException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
HyperNet is a dial up Internet accelerator that boosts your Web surfing experience using your existing phone jack and modem with NO additional equipment and NO waiting! It's the hi-speed surfing solution with the convenience of dialup Internet Service!
A krishnamurthy number is one whose sum of the factorials of each number is equal to the number itself. Example
145
sum of factorial of each digits = 1+24+120 = 145 which is the number itself.
A statement is a single instruction in a language; a block is a group of instructions.
What are high and low level languages?
Low level languages expose the internals of a computer's processor and allow you to take advantage of the power of that processor. Every processor has an assembler which allows you to code directly the machine language processed by the processor. This is the lowest level language available, however, the downside is that you are stuck producing code for only one processor and it will take a long time to write any significant program.
The next higher level language will be things like C, which are compiled fairly efficiently down to the machine level. C being higher level can be written and supported by many processors out there. It takes less C code to write a significant program than assembler.
The higher the level of a language the less code that is necessary to write a significant program, however, these programs are no longer efficient in terms of the amount of machine language generated. These programs often run slower and require large amounts of code to do simple things; this is counterbalanced by the ability to get complex things done with very little code. Many higher level languages are called 4GL for 4th generation languages.
A quantitative definition of 4GL has been set by Capers Jones, as part of his work on function point analysis. Jones defines the various generations of programming languages in terms of developer productivity, measured in function points per staff-month. A 4GL is defined as a language that supports 12-20 function points per staff month. This correlates with about 16-27 lines of code per function point implemented in a 4GL.
Benefit of inner class in java?
Inner classes are very useful for classes that are written specifically to be used with the encompassing class. A good example of this would be a LinkedListNode class being part of a LinkedList class:
public class LinkedList {
private LinkedListNode root;
private class LinkedListNode {
private Object data;
private LinkedListNode nextNode;
}
} No class except your LinkedList class needs to know anything about the LinkedListNode class. So we hide it so no one else needs to worry about what it does.
What are non static members in Java?
Local variables (on the stack) or dynamically allocated variables (in the heap) are nonstatic variables. Static variables, constants and globals are all allocated in the program's data segment.
How do you get your nested loop to decrement and not increment?
Easy. Change any + to -, any += to -=, any ++ to --
Why do you need to implement FTP in JAVA?
FTP is a commonly used protocol used to transfer files. There are many ready-made solutions; it might not be necessary to program it. On the other hand, you may need to integrate FTP into some other application. In other words, if you already decided to program in Java, you may need to add FTP capabilities to it.
Java uses the least-abstract implementation of a method. If a method is called on an object, it searches the current object for an implementation. If no such implementation exists, Java looks to the object.super class for the method. It keeps searching up the superclass list until it finds a method or gets to the Object superclass and throws a NoSuchMethodException.
Write a program to show the applet life cycle?
What does generate random numbers mean?
It means to get a number, randomly, from a certain range of numbers.
It means to get a number, randomly, from a certain range of numbers.
It means to get a number, randomly, from a certain range of numbers.
It means to get a number, randomly, from a certain range of numbers.
When is a number called a 'Sunny' number?
A number is said to be 'sunny' when, 1 added to that number, the square root of it becomes a whole number...
What ways can object oriented systems be considered cure to the software crisis?
It isn't clear what you mean by the "software crisis". The benefits of object oriented systems are usually in the re-use of code (not having to write the same type of code over and over again), which leads to a better ROI (return on investment).
This means you can leverage what you already have done to get a product to market faster.