xxxxxxxxxx
public class Main {
public static void main(String[] args) {
// 1. What is Java?
System.out.println("Java is a high-level programming language developed by Sun Microsystems.");
// 2. What are the main features of Java?
System.out.println("The main features of Java include object-oriented programming, platform independence, garbage collection, and exception handling.");
// 3. What is the difference between the '==', 'equals()', and 'hashCode()' methods?
System.out.println("The '==' operator checks for reference equality, 'equals()' method checks for object equality, and 'hashCode()' method returns a hash code value.");
// 4. What is the difference between abstract classes and interfaces?
System.out.println("Abstract classes can have constructors and implementation code, while interfaces cannot. A class can implement multiple interfaces but can only extend one abstract class.");
// 5. What is the difference between checked and unchecked exceptions?
System.out.println("Checked exceptions are checked at compile-time, while unchecked exceptions are not. Checked exceptions must be either handled with try-catch or declared with throws keyword.");
}
}
xxxxxxxxxx
public
class
MathTest
public void main(String[] args)
int
X
10
*
10
-10
; System.
out
.println(x); } }
xxxxxxxxxx
Input:
7
1 2 3 2 5 9 0
4
Output: First Index = 1 Last Index = 3
xxxxxxxxxx
import requests
from bs4 import BeautifulSoup
# Send a HTTP GET request to search for Java interview questions
response = requests.get('https://www.javatpoint.com/java-interview-questions')
# Parse the HTML content of the response
soup = BeautifulSoup(response.content, 'html.parser')
# Find all the question elements in the HTML
question_elements = soup.find_all('div', class_='qusans')
# Iterate over the question elements and extract the questions
questions = [question.find('a').text for question in question_elements]
# Print the top Java interview questions
for i, question in enumerate(questions[:10], start=1):
print(f'Question {i}: {question}')
xxxxxxxxxx
1. public class InterviewBit
2. {
3. public static void main(String[] args) {
4. final int i;
5. i = 20;
6. int j = i+20;
7. i = j+30;
8. System.out.println(i + " " + j);
9. }
10. }