Java and C Programming Fundamentals
Questions covering Java threading, exceptions, OOP features, and C operators, data types, and arithmetic operations.
Questions
Which of the following accessibility modes in Java does not allow a method to access the data members from the non-subclass of the same package?
- Protected
- Public
- Private
- No modifier
- Virtual
Which of the following methods of Iterator class throws NoSuchElementException, if the next element does not exist?
- hasNext()
- next()
- remove()
- add()
- nextIndex()
Which of the following Exception classes in Java is used to deal with an exception, where an assignment to an array element is of incompatible type?
- ArithmeticException
- ArrayIndexOutOfBoundsException
- IllegalArgumentException
- ArrayStoreException
- IllegalStateException
Which of the following methods is used in Thread class to resume the execution of a Thread class?
- yield()
- setName()
- resume()
- isAlive()
- start()
Which of the following methods in Java is used to identify that the input argument is a letter?
- isDefined()
- isDigit()
- isLetter()
- isLowerCase()
- isSpaceChar()
Which of the following methods in StringBuffer class concatenates two strings of different types to the end of the invoking string object?
- getChars()
- append()
- insert()
- reverse()
- delete()
Which of the following methods of Class returns the complete name of the class or interface of the invoking object?
- getSuperclass()
- isInterface()
- getName()
- toString()
- getClasses()
Consider the following C statement.
int a = 5;
printf(a = %usizeof(a));
What would be the output of the above C code?
- a = 1
- a = garbage value
- a = 2
- Compiler error
- None of these
Consider the following C statements.
int i,alpha = 65;
char ch[27];
for(i = 0;i<2;i++)
{
ch[i] = alpha;
alpha = alpha + 1;
}
printf(!!!^!!!%s!!!^!!!,ch);
What would be the output of the above C code?
- AB
- ABC
- 6566
- Compiler error
- 01
What would be the value of variables n and m in the following C code?
int n, m;
n = - 10;
m = - n + 5;
printf(!!!^!!!n = %dnm=%d!!!^!!!,n,m);
- n = - 10 m = - 5
- n = - 10 m = Garbage value
- n = - 10 m = 15
- n = 10 m = 5
- Compiler error
What would be the output of the following C statement?
char ch;
ch = 'A';ch = - ch + 'a';
printf(!!!^!!!ch = %d!!!^!!!,ch);
- ch = 162
- ch = 32
- ch = - 32
- Compiler error
- ch = 65
What would be the value of the following C code?
float a;
a = floor(6.523);
printf(!!!^!!!a = 0.2f!!!^!!!,a);
- a = 6.00
- a = 6.60
- a = 7.00
- a = 6.70
- Compiler error
By default, the floating-point value displays ______________ digits after the decimal point.
- 3
- 2
- 6
- 4
- none of these
Consider the following C statement.
int a = 3,b = 2;
a+ = b++;
printf(!!!^!!!a = %d!!!^!!!,a);
What would be the value of 'a'?
- a = 6
- a = 5
- a = 4
- a = 3
- Compiler error
Which of the following methods in Thread class, checks that the thread is a daemon thread?
- join()
- isDaemon()
- activeCount()
- sleep()
- start()