Interview Questions C and Java
Interview Questions C and Java
Interview Questions C and Java
21. If I write System.exit (0); at the end of the try block, will
the finally block still execute?
When you type System.exit(0) in the end it indicates the
compiler to stop compiling and execute of the program, thus
the finally block will not be executed.
10. Does Java provide any constructor to find out the size
of an object?
There is no sizeof operator in java. It is not possible to
determine the size of the object directly in java.
3.What do the ‘c’ and ‘v’ in argc and argv stand for?
c in argc stands for count
v in argv stands for vector
17. Can you use the function fprintf() to display the output on the
screen?
fprintf() is used to write data into the file. hence it cannot
be used to display the data in the screen.
void main()
{
int const * a=5;
printf("%d",++(*a));
}
The following will have compile time error. Since, a variable declared
constant has been modified.
2.What if the function of clrscr()?
clrscr() is a function that creates a new screen or creates a screen full
of dots which is nothing but clearing the screen.
#include
int main ()
{
int a [5];
a [3] = 1111;
printf ("3[a] = %dn", 3[a]);
return 0;
}
The above code will work since when the program is executed. the
compiler coverts it into pointer function *(a + 3) for a[3]. Same conversion
only it does for 3[a]. This can work out in printf but not in scanf.
13. How would you detect a loop in a linked list? Write a C program to
detect a loop in a linked list.
Two methods available to detect a loop in a linked list.
• One way of detecting is through is to flag the link visited
• Have 2 pointers to start of the linked list. Increment one pointer by 1
node and the other by 2 nodes. If there's a loop, the 2nd pointer will meet
the 1st pointer somewhere. If it does, then you know there's one.
6) If You join the company then what is the first thing you
want to do , which you were not able to do in ur previous
company?
This is to ensure the commitment towards the job. As soon
as you join the company the main goal of the job seeker should
be able to fulfill the task and responsibility given to you. The
applicant should be able to expand the skill and task apart from
the normal task assigned to him/her.
13) What are the Call Center and Customer Service main
objectives?
This will help the recruiter how far he/she will be able to
satisfy the customer and to manage the customer effectively.
Answer:-
The main objective of the customer service is to provide
customer satisfaction and retention which is very much
essential to sustain as well for future progress of the
organization. Call centre consist of different kinds of customer
and of different type. Inorder to create an awareness about the
customer such question are asked in the interview.
4) What is typecasting?
Typecasting converts entity of one type to entity of another type. It is very
important while developing applications.
Casting is of two types:-
1. downcasting
2. Upcasting
C QUESTIONS
11) What are the rules for constructing the real constant?
* A real constant should have atleast one digit
* It should be a decimal point
* By default it is assigned positive value
* Within real constant no blank space or commas.
JAVA QUESTIONS
What is an object?
An object is an entity, which consist of attributes, behaviors and qualities
that describe the object.
2) What is a class?
A class represents a collection of attributes and behaviors of object. It is
the class from which individual objects created.
For example:-
Bicycle is a class that contain the following attributes
Speed
Gear
3) What is OOAD?
OOAD stands for Object Oriented analysis and design. It is a
methodology use to analyze, design and develop applications. It visualizes
the class and the objects.
C QUESTIONS
Char *a = “Name”
in front of a shows pointer declaration. The complier asks to place to
hold the pointer. Memory address will given the name ‘a’ and it points to the
array of seven character.
The two functions mainly is to allocate memory and they are commonly
called as memory managers.
Calloc() :- Calloc function take two argument in a time. The bits in the
allocated space are initialized to zero.
Program which uses const declaration should not override using type
cast. This will cause the program not to run sucessfuly. Type cast cannot
be used to turn pointer from one data type to another.
Switch statement is better used when it required to check more then one
condition with the same variable. A switch statement check the condition
only ones.
For example: - %f This tells that the value will be in floating point
Any variable declared inside the function are said to be local variable.
These variable have meaning only within the function. Any variable
declared outside the function are said to be global variable
Stack operates under the rule of last in, first out. It contains two basic
operations Pop and push. A stack can hold any data type. Stack doesn’t
perform flexible operation.
Strcat(str, “programming”)
Output :- C programming
Elements in a array are for char data type and can store single
character in each element. The significant use of array is that the ability to
store the strings as text.
Int
Float
Char
Double
Static variable are constant variable whose value remain the same
throughout the program. Static variable are instant variable
22) How can you determine the size of an allocated portion of the memory?
Fopen():- function to open a file, the pointer points to the first record in
the file.
Fwrite:- This function write data in the file were the pointer is pointing.
25) What are logical operators in C?