What is the difference between C and java?
No. Java source code and C source code may look similar (since Java is based on C++, which is based on C), but the languages themselves are very different.
Yeah both are totally different language based on different paradigm JAVA is Object-Oriented while C is procedural.C breaks down to functions while JAVA breaks down to Objects. C is more procedure-oriented while JAVA is data-oriented.C is a low-level language while JAVA is a high-level language.Java is an Interpreted language while C is a compiled language.
What are the different types of Operators available in java?
arithmatic operator +,-,*,/,%
assigment oprator ==
logical operator &,|,^,&&,,!
bitwise opertor &,|,^
left shift <<
right shift >>
left shift zero fill <<
assignment operator +=,-=,*=,/=
Why people generally use oracle as backend of java projects?
there are certain rules to make up a relational data base management system, oracle follows it and so its an rdbms
What a java program for arithmetic operations between two integers?
public static void main(String[] args) {
int a = 5;
int b = 10;
int c;
c = a + b; // addition
c = a - b; // subtraction
c = a * b; // multiplication
c = a / b; // division
}
How ploymorphism and inheritance is different from that in Java and c plus plus?
C++ allows multiple inheritance while Java does not. In my opinion, multiple inheritance is not useful because it can get very confusing very quick.
For polymorphism, C++ does early binding by default, while Java does late binding by default. Late binding is more useful than early binding.
Is it possible to use arrays when using the java programming language?
It is possible to use arrays when employing java programming language. There are many different series of programming choice that can be employed with various end results.
Why is it important to have a solid background in mathematics for programming languages?
You need to to know some basic math to live. right? Likewise you need to know some basic math to start computer programming....beginners start out by learning to do programs like solving a quadratic equation....if you are not thorough with algebra, u can't do it. The way you think is more important.....rather than being good in math, computer programmers are required to think the way math people think - vey very very logically.
Which type of inheritance does not support by java?
Desoola Anil Kumar, Java Faculty: There are 5 types of Inheritance. 1.Single inheritance, 2.Multiple inheritance, 3.Multilevel Inheritance, 4. Hirarichal inheritance and 5. Hybrid inheritance. Java supports multi level inheritance and hirarichal inheritance.
When do you say an exception is handled?
There is no catch block that names either the class of exception that has been thrown or a class of exception that is a parent class of the one that has been thrown, then the exception is considered to be unhandled, in such condition the execution leaves the method directly as if no try has been executed
C program to read a text and count occurrence of a particular word?
#include<stdio.h>
main()
{
int i,words,spaces;
char a[30];
printf("enter the string") ;
scanf("%s",a);
for(i=0;a[0]!="\0";i++)
{
if (a[i]=' ')
spaces++;
}
printf("the no. of spaces in the string is %d",spaces);
printf("the number of words in the string is %d",spaces+1);
}
Program for dequeue in data structure?
Display function in de queue
void display()
{
int i;
if((front == -1) (front==rear+1))
printf("\n\nQueue is empty.\n");
else
{
printf("\n\n");
for(i=front; i<=rear; i++)
printf("\t%d",queue[i]);
}
}
Write a test program that prints a 3 by 3 matrix?
4.(Displaying matrix of 0s and 1s ) write a method that displays by n by n matrix using the following header : Public static void printMatrix(int n) Each element is o or 1,which is generated randomely. Write a test program that prints a 3 by 3 matrix that may look like this: 010 000 111 4.(Displaying matrix of 0s and 1s ) write a method that displays by n by n matrix using the following header : Public static void printMatrix(int n) Each element is o or 1,which is generated randomely. Write a test program that prints a 3 by 3 matrix that may look like this: 010 000 111
Explain the meaning of abstract keyword in relation to classes and methods?
The abstract keyword is used to denote abstract classes and abstract methods in Java.
An abstract method is a method which is defined, but not implemented:
public abstract void doStuff();
An abstract class is a class which contains one or more abstract methods*, and which cannot be instantiated directly. All subclasses of an abstract class must implement the abstract methods.
* Note that abstract classes can include no abstract methods, but this rather defeats the purpose of using an abstract class.
The quintessential example of an abstract class is the Shape class.
// Definition of our abstract class
public abstract class Shape {
// Notice how we can actually declare and implement variables and methods.
// This is what differentiates between an abstract class and an interface.
// The location of this shape
private double x,y;
// Change our location - all subclasses will have this by default
public void moveTo(final double newX, final double newY) {
x = newX;
y = newY;
}
// Definitions of our abstract classes.
// All classes which extend from Shape must implement these.
public abstract double getArea();
public abstract double getPerimiter();
}
// Definition of our concrete example class
public class Rectangle extends Shape {
// Beyond the x,y location of Shape, Rectangle must have width and height
private double width, height;
// Implement abstract methods
public double getArea() {
return width * height;
}
public double getPerimiter() {
return width + width + height + height;
}
}
Can you have a final abstract class?
No. The abstract keyword means that you cannot instantiate the class unless you extend it with a subclass. The final keyword means that you cannot create subclasses of that class.
Combining them would lead to an unusable class, so the compiler will not let this happen.
class firstprog
{
public static void main (String args[])
{
System.out.pritnln("My first Program in Java ");
}
}
Simple Java Programe
Write the above program in Ms dos's edit or Notepad of Windows save it with "firstprog.java" run the commands given below in command prompt of Ms Dos to get the output Remamber Java is case sensative so mentain capital and small letter.
1. javac firstprog.java
2. java firstprog
What is an abstract interface?
An abstract interface is an interface which has a one-to-many relation - providing multiple paths from a single location to multiple locations.
You can also write desktop programs. You can use Java for almost anything.
You can also write desktop programs. You can use Java for almost anything.
You can also write desktop programs. You can use Java for almost anything.
You can also write desktop programs. You can use Java for almost anything.
What is relationship between string and char data type?
The char type store only one symbol of data (letter, digit, space, tab and so on). The string type is able to keep virtually data of any length. Also string type is based on arrays and uses reference type working with memory.
How java runs in command prompt?
The Java executable comes with a showversion flag, so typing:
java -showversion
Will display something like:
java version "1.6.0_16"
Java(TM) SE Runtime Environment (build 1.6.0_16-b01)
Java HotSpot(TM) 64-Bit Server VM (build 14.2-b01, mixed mode)
Note: This seems to be bugged on my machine. After printing out the above information, it also prints out the rest of the command line switches. If this happens to you, you may have to scroll up to see the important information.
Write a program that accepts a word in uppercase and prints it in lowercase?
There are two functions in ctype.h: toupper() and tolower(). First one to make character into upper case and the second one for making lower case.
Here is a small program converting inputted character into lower case:
#include
#include
int main() {
char ch;
printf("Enter the char: ");
scanf("%c", &ch);
printf("Char in lowercase: %c\n", tolower(ch));
return 0;
}
Testing:
Enter the char: G
Char in lowercase: g
Enter the char: S
Char in lowercase: s
What operator can be used to compare 2 values in java?
One possible way (although much less efficient than using the operators directly) is by using BigInteger:
int a = 5, b = 7;
int sum = BigInteger.valueOf(a).add(BigInteger.valueOf(b)).intValue();
However, BigInteger.add() might use arithmetic operators in its own calculations; they are simply hidden from the programmer's view.
Thread can be created in two ways either by extending Thread or implementing runnable interface
Examples:
public class A extends Thread { } public class A implements Runnable { } By using both the methods we can create a Java Thread. The disadvantage of extending the Thread class is that, you cannot extend the features of any other class. If we extend the Thread class we cannot extend any other class whose features we may require in this class.
So it is usually advisable to implement the Runnable Interface so that we can extend the required features and at the same time use the Thread functionality.
How many classes are there in java?
For a Java program to run for a user it must contain at least one method called main and can contain an unlimited amount of other methods. However, java classes do not need a main method.
So, your answer is: [1, ∞)What are Class Constructor and Primitive data types?
class constructor is a function which has the same name as the class name and has no return type.
primitive data types are the fundamental data types which are independent.
eg:int,char,float etc..............