How do you say daddy in binary code?
It depends on the encoding but if we assume standard ASCII encodings, the representation is the same for all systems, the only difference being the number of leading 0 bits per character.
7-bit ASCII (ISO/IEC 646):
1100100 1100001 1100100 1100100 1111001 0000000
8-bit ASCII (ISO/IEC 8859, Windows-1252 and UTF8):
01100100 01100001 01100100 01100100 01111001 00000000
UTF16:
00000000 01100100 00000000 01100001 00000000 01100100
00000000 01100100 00000000 01111001 00000000 00000000
To perform these conversions, convert each character to its ASCII representation (in decimal):
d = 100
a = 97
d = 100
d = 100
y = 121
For completeness, we should also include the null-terminator, character code 0.
null = 0
Now convert each decimal value to its 8-bit representation in hexadecimal:
100 = 0x64
97 = 0x61
100 = 0x64
100 = 0x64
121 = 0x79
0 = 0x00
Convert each hexadecimal digit to its 4-bit binary representation:
0x6 = 0110
0x4 = 0100
0x6 = 0110
0x1 = 0001
0x6 = 0110
0x4 = 0100
0x6 = 0110
0x4 = 0100
0x7 = 0111
0x9 = 1001
0x0 = 0000
0x0 = 0000
Place the binary codes in sequence.
"daddy" = 01100100 01100001 01100100 01100100 01111001 00000000
Finally, add or remove leading zero bits to suit the actual encoding.
What is the meaning of abstract in java?
: Abstraction is simplifying complex reality by modelling classes appropriate to the problem, and working at the most appropriate level of inheritance for a given aspect of the problem. : For example, Lassie the Dog may be treated as a Dog much of the time, a Collie when necessary to access Collie-specific attributes or behaviors, and as an Animal (perhaps the parent class of Dog) when counting Timmy's pets.
Abstraction is also achieved through Composition. For example, a class Car would be made up of an Engine, Gearbox, Steering objects, and many more components. To build the Car class, one does not need to know how the different components work internally, but only how to interface with them, i.e., send messages to them, receive messages from them, and perhaps make the different objects composing the class interact with each other.
Writing in pseudo code means writing in a natural language, not in any specific programming language, so there is no thing as "pseudo-code used in C" as opposed to "pseudo-code used in Java".
When you write in pseudo-code, you don't have to follow any specific syntactic rules, just to describe the steps you will use in your algorithm.
For example, pseudo-code for bubble sort (taken from wikipedia):
procedure bubbleSort( A : list of sortable items ) do swapped = false for each i in 1 tolength(A) - 1 inclusive do: if A[i-1] > A[i] then swap( A[i-1], A[i] ) swapped = true end ifend for while swapped end procedure
It is not written in any programming language, but it should be easy to implement this in any language after you understand the idea from the pseudo-code.
What is the purpose of using final keyword with a class declaration?
The final keyword is used in several different contexts as a modifier meaning that what it modifies cannot be changed in some sense. public final class String This means this class will not be subclassed, and informs the compiler that it can perform certain optimizations it otherwise could not. It also provides some benefit in regard to security and thread safety. The compiler will not let you subclass any class that is declared final. You probably won't want or need to declare your own classes final though. You can also declare that methods are final. A method that is declared final cannot be overridden in a subclass. The syntax is simple, just put the keyword final after the access specifier and before the return type like this: public final String convertCurrency() You may also declare fields to be final. This is not the same thing as declaring a method or class to be final. When a field is declared final, it is a constant which will not and cannot change. It can be set once (for instance when the object is constructed, but it cannot be changed after that.) Attempts to change it will generate either a compile-time error or an exception (depending on how sneaky the attempt is). Fields that are both final, static, and public are effectively named constants.
In computer science, a hash table, or a hash map, is a data structure that associates keys with values. The primary operation it supports efficiently is a lookup: given a key (e.g. a person's name), find the corresponding value (e.g. that person's telephone number). It works by transforming the key using a hash function into a hash, a number that is used as an index in an array to locate the desired location ("bucket") where the values should be. Hash tables support the efficient insertion of new entries, in expected O(1) time. The time spent in searching depends on the hash function and the load of the hash table; both insertion and search approach O(1) time with well chosen values and hashes.
Object oriented design and procedural oriented design?
In object oriented programming main role plays objects and classes, in structure programming all programmes are represented as structures of block's, in procedure programming - that means high level programming languages, which are based on process description (sequence of processes) - all programmes are described like a set of subprogrammes or procedures.
For more information you may search these articles:
http:/en.wikipedia.org/wiki/Object-oriented_programming
http://alarmingdevelopment.org/?p=9
http:/en.wikipedia.org/wiki/Procedural_programming
What is the purpose of a function or procedure?
function is a set of statements that can be executed in the part of the program.
ex: to add two nos. using function
void main()
{
int a,b,c;
printf("enter the two numbers");
scanf("%d%d",&a,&b);
add(a,b);
clear();
}
void add(int a,int b)
{
c=a+b;
printf("the sum is %d",c);
}
Can we write static public void main in java?
the method of an class that can is triggered when starting a Java application e.g. by running the command: "java MyProgram"
Answer
Public is an Access Specifier,static is a keyword which illustrates that method shared along all the classes.void illustrates that this method will not have any return type.main is the method which string has an argument. Public specifier makes the method visible outside the Class and because of the static nature of the method, JVM can call this main method without instantiating the class 'MyProgram'.
Declaration can appear anywhere in the body of java method ATrue B False?
Partially true and partially false.
A variable's declaration must happen atleast one life before the usage of that variable. Therefore we can take this as declaration can be done anywhere provided we declare it before the usage. otherwise it would throw a compilation error.
What is purpose of abstraction in java?
Abstract keyword used for method declaration declares the methods without implementations.
Abstract class in java have abstract methods that is not implemented in abstract class, but implemented in subclasses in java program. If the class in java program is not required to get instantiated than that class use the abstract keyword but this class rather is available for other classes to extend by other classes.
Abstract keyword will be used in method declaration to declare that method without providing the implementation in that java program. In other words we can say that, it formally unfinished class as well as method, that marked with the help of keyword abstract.
Defining abstract is a way of preventing someone from instantiating a class that is supposed to be extended first. In java program abstract class is deliberately missing similar to like an interface which will missing all method bodies in the program. Abstract class provides a way to extend an actual class. We will not use new on abstract classes but will use abstract references in the java program, that always point to objects of the class that extends an abstract class.
In java program for practical use of an abstract class, we will define a non-abstract class that extends an abstract one. This will use any of the inherited non-abstract methods.
Most of the time abstract class may extend another abstract class. In that condition it need not implement all in the non-abstract methods. An abstract keyword used both on classes and methods. In case of class declared with an abstract keyword may not be instantiated that is the only thing that abstract keyword doing.
How operator overloading differ from function overloading?
Function overloading is multiple definition with different signatures(the parameters should be different) for the same function. The parameter list have to be different in each definition. The compiler will not accept if the return type alone is changed.
Operator overloading is defining a function for a particular operator. The operator loading function can not be overloaded through function overloading.
Actually, the Java compiler is not considered slow when compared to compiling a similar project in C or C++. The Java compiler itself is actually quite simple. All of the fancy Java optimizations occur during runtime.
As someone who used to work on the Sun JDK at Sun itself, I can tell you that the old javac (pre-2010 or so) was rather simplistic. Remember that javac itself is a Java program, so that to run, it must first invoke a JVM, and incurs typical JVM load and initialization time. It was originally designed to work on the 'fork/exec' model so common to UNIX, where it would fork a new instance of javac (and the associated JVM required to run it) for every file that it compiled. Now, creating a new JVM had significant startup time costs (initialization of methods was nontrivial), but javac would run reasonably fast one that happened. However, having to fork several hundred times during a single project compile got expensive, and slow. This was particularly true on Windows, where a 'fork/exec' call is over 10x as slow as on a UNIX or Linux system.
So, the 'old' javac, while quite quick to actually compile a single file after it got running, was actually quite slow overall when forced to compile a large number of source code files.
A major revamp of the javac compiler was undertaken during 2010 with JDK 7. This revamp significantly reduced the number of times a fork/exec was done, buy reusing existing JVMs to run several (sequential) invocations of the javac language. This significantly improved large project compile times, as it reduced the primary overhead that was slowing things down. There are additional projects being worked on that will turn javac into a single multi-threaded program able to compile multiple files itself in one invocation, thus eliminating the need to spawn multiple JVMs. This will particularly help Windows compiles, as Windows threading is much faster than fork/exec.
So, overall, if you are running a JDK with a javac created BEFORE mid-2010, javac will be relatively slow for compiling lots of source files, and worse on Windows. Pretty much all Sun/Oracle JDK 6 versions (even the newest ones) have this "defective" javac. The newer, faster javac is available in JDK 7 - I believe it may not be in JDK7, but is definitely in JDK 7 Update 1 and later. This javac should feel quite responsive for most projects, and only be a bit slow on large Windows compiles (more than 100 source files or so), and, even there, will be a noticeable improvement over the JDK 6 javac program.
What is Thread Synchronization?
Thread synchronization requires that a running thread gain a "lock" on an object before it can access it. The thread will wait in line for another thread that is using the method/data member to be done with it. This is very important to prevent the corruption of program data if multiple threads will be accessing the same data. If two threads try to change a variable or execute the same method at the same, this can cause serious and difficult to find problems. Thread synchronization helps prevent this.
Many programming languages, operating systems, and other software development environments support what are called "threads" of execution. Threads are similar to processes, in that both represent a single sequence of instructions executed in parallel with other sequences, either by time slicing or multiprocessing. Threads are a way for a program to split itself into two or more simultaneously running tasks. (The name "thread" is by analogy with the way that a number of threads are interwoven together)
What is a Java program that finds the greatest common factor of two integers?
The easiest way to find the greatest common denominator of two integers with a computer program is to use the Euclidean algorithm. Of the most popular methods of finding the GCD of two numbers, the Euclidean algorithm does it with the least amount of work and requires the least amount of code.
In order to understand the Euclidean algorithm, you'll need to know a few division terms:
A is the dividend, B is the divisor, C is the quotient, and D is the remainder.
The Euclidean algorithm works like this:
If you still don't get it, try looking at the Euclidean algorithm in action:
Find the GCD of 84 and 18.
You should now have a good grasp of how the Euclidean algorithm works. Now we need to turn it into code. We'll need three variables, all of them integers:
int divisor, dividend, remainder;
The purpose of the variables is self-explanatory. Next, we need to make a few decisions. We need to decide if the dividend or the divisor is 0. If that test is passed, then we need to decide if the dividend or the divisor is 1. If that test is passed, then we need make sure that dividend is larger than divisor.
if(dividend 1) {
printf("The GCD is 1.\n");
}
// Make sure the dividend is greater than the divisor.
if(divisor > dividend) {
remainder = dividend;
dividend = divisor;
divisor = remainder;
}
// Calculate the GCD.
while(remainder != 0) {
remainder = dividend % divisor;
dividend = divisor;
divisor = remainder;
}
// Display the answer to the user.
printf("The GCD is %i.\n", dividend);
}
And the GCD lived happily ever after. The end.
Can you define a constructor as private?
I dont think we can have Protected Constructors but yes we can have Private constructors.
We can declare the constructor as Private to ensure that no other class can instantiate it. We use this in the singleton design pattern
What is class in oops concept?
Classes are the integral part of the all-important programming paradigm known as Object-Oriented Programming(OOP). In OOP, a programming problem is perceived as a problem in a real-life scenario, as an interaction between objects. The problem is tackled by having a system of interacting objects, that interact among themselves to solve the programming problem. Objects in OOP bear semblance to real-life objects. Classes serve as templates for the creation of objects of the same type. For instance, students may be thought to be objects of the human-being class, cars may be thought to be objects of the Automobile class. Classes are defined as collection of methods(functions) and data members(variables), additionally defined by scope rules. In addition, classes also achieve the OOP principles of encapsulation, abstraction, polymorphism and inheritance. Encapsulation refers to binding data and code together, with data controlling access to code. Abstraction refers to the hiding the implementation details of a class from outside functions and exposing only necessary details. Polymorphism refers to the scenario when a class can play more than one role. Inheritance is used when one or more classes must include properties of another set of classes, and also have properties of their own.
A data type consisting of more than one letter, like a word or a sentence. A single letter is normally known as a character data type. Normally strings are enclosed in double quotation marks and single letters are enclosed in single quotations marks:
'a'
"animal"
How can Boolean be used in Java?
An expression is anything that can be evaluated ("calculated"), to get a value. Numeric expressions are more common: anything that you can calculate, and get a number. For example, if a and b are numbers, a + b will give you another number - it is therefore a numeric expression. The variables by themselves are also numeric expressions.
A boolean expression is anything that you can evaluate and get a result that is boolean, i.e., either true or false. Here are some examples:
a == b
a > b
a >= 5 && a <= 10 // && means "and"
Any method that returns either true or false, for example (for the String class) the method matches(), which states whether the string does, or does not, match a certain pattern.
An expression is anything that can be evaluated ("calculated"), to get a value. Numeric expressions are more common: anything that you can calculate, and get a number. For example, if a and b are numbers, a + b will give you another number - it is therefore a numeric expression. The variables by themselves are also numeric expressions.
A boolean expression is anything that you can evaluate and get a result that is boolean, i.e., either true or false. Here are some examples:
a == b
a > b
a >= 5 && a <= 10 // && means "and"
Any method that returns either true or false, for example (for the String class) the method matches(), which states whether the string does, or does not, match a certain pattern.
An expression is anything that can be evaluated ("calculated"), to get a value. Numeric expressions are more common: anything that you can calculate, and get a number. For example, if a and b are numbers, a + b will give you another number - it is therefore a numeric expression. The variables by themselves are also numeric expressions.
A boolean expression is anything that you can evaluate and get a result that is boolean, i.e., either true or false. Here are some examples:
a == b
a > b
a >= 5 && a <= 10 // && means "and"
Any method that returns either true or false, for example (for the String class) the method matches(), which states whether the string does, or does not, match a certain pattern.
An expression is anything that can be evaluated ("calculated"), to get a value. Numeric expressions are more common: anything that you can calculate, and get a number. For example, if a and b are numbers, a + b will give you another number - it is therefore a numeric expression. The variables by themselves are also numeric expressions.
A boolean expression is anything that you can evaluate and get a result that is boolean, i.e., either true or false. Here are some examples:
a == b
a > b
a >= 5 && a <= 10 // && means "and"
Any method that returns either true or false, for example (for the String class) the method matches(), which states whether the string does, or does not, match a certain pattern.
Any kind of sequential program is not a good candidate to be threaded. An example
of this is a program that calculates an individual tax return. (2) Another example is a
"shell" program such as the C-shell or Korn shell. Such a program must closely
monitor its own working space such as open files, environment variables, and
current working directory.
Data types in c primitive and non primitive?
Primitive types are the data types provided by a programming language as basic building blocks. Primitive types are also known as built-in types or basic types.
Depending on the language and its implementation, primitive types may or may not have a one-to-one correspondence with objects in the computer's memory. However, one usually expects operations on primitive types to be the fastest language constructs there are. Integer addition, for example, can be performed as a single machine instruction
What is the different between java applets java application?
Servlets is a application that running on the server, when a server receive a request of a servlet, the server will process the servlet and give the result to the client back after the servlet is done.
WAP to print sum and average of multiples of 5 from 500 to 600?
public class Test {
public static void main(String[] args){
int i = 500;
int sum = 0;
int avg = 0;
int counter = 0;
do {
i = i + 5;
sum = sum + i;
counter = counter + 1;
} while (i <= 600);
System.out.println("Sum: " + sum);
avg = sum/counter;
System.out.println("Average: " + avg);
}
}