JAVA
2.7K subscribers
73 photos
111 files
76 links
Download Telegram
Forwarded from Hasta Hua
Java interview questions (1).pdf
213.4 KB
JAVA pinned Deleted message
public class Program
{
private int num; private Program(){ System.out.print("Constructor"); num=5; } public static void main(String[] args) { Program p=new Program(); System.out.println(p.num); } }
Anonymous Quiz
32%
Compile Time Error
14%
0
55%
Constructor 5
0%
No Output
public class Program
{
public static void main(String[] args) { int t; System.out.println(t); } }
Anonymous Quiz
39%
0
35%
Compile Time Error
17%
Runtime Error
9%
None Of the Above
Functionality of multiple inheritance can be implemented in java by
A) Extending one class and implementing multiple Interfaces
B)Implementing multiple Interfaces C)Extending multiple classes and interfaces D)Extending multiple classes and one Interface
Anonymous Quiz
37%
Only A
11%
Only B
26%
A & B
26%
B & C
Which of the following variable declaration would NOT compile in a java program?
Anonymous Quiz
0%
int var;
4%
int VAR;
8%
int var1;
4%
int var_1;
85%
int 1_var;
Consider the following class definition:
public class MyClass
{
private int value;
public void setValue(int i){ /* code */ }
// Other methods...
}
The method setValue assigns the value of i to the instance field value. What could you write for the
implementation of setValue?
(a) value = i;
(b) this.value = i;
(c) value == i;
(d) Both (A) and (B) and above
(e) (A), (B) and (C) above.
Options
Anonymous Quiz
13%
A
31%
B
13%
C
44%
D
0%
E
You read the following statement in a Java program that compiles and executes.
submarine.dive(depth);
What can you say for sure?
Anonymous Quiz
0%
depth must be an int
23%
dive must be a method.
32%
dive must be the name of an instance field.
36%
submarine must be the name of a class
9%
submarine must be a method.
The java run time system automatically calls this method while garbage collection.
Anonymous Quiz
9%
finalizer()
55%
finalize()
24%
finally()
12%
finalized()