U1) An Introduction To Core Java Flashcards

(26 cards)

1
Q

Who developed Java and when?

A

James Gosling in 1995 at Sun Microsystems.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What was Java originally called?

A

Oak.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the main feature of Java?

A

Write Once, Run Anywhere (WORA).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

List key features of Java.

A

Platform Independent, Object-Oriented, Simple, Secure, Robust, Multithreaded, Portable, High Performance, Distributed, Dynamic.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How does Java ensure security?

A

Bytecode verification, Security Manager, sandboxing, and no direct memory access.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do you run a Java program using the command line?

A

Compile with ‘javac FileName.java’, run with ‘java FileName’.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do you create and run a Java program in an IDE?

A

Create new project, add class, write code, and run using IDE buttons.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are basic programming constructs in Java?

A

Decision-making (if, else, switch), looping (for, while, do-while).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a class in Java?

A

A blueprint for creating objects.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is an object in Java?

A

An instance of a class.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is a constructor in Java?

A

A special method used to initialize objects.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Define encapsulation.

A

Wrapping data and code into a single unit (class).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Define abstraction.

A

Hiding internal details and showing functionality only.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Define inheritance.

A

One class acquires the properties of another using ‘extends’.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Define polymorphism.

A

The ability of one method to behave differently in different situations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How to use ‘super’ keyword?

A

To access parent class methods or constructor.

17
Q

How to use ‘this’ keyword?

A

Refers to the current class object.

18
Q

What does the ‘final’ keyword do?

A

Prevents method overriding or class inheritance.

19
Q

What is an interface in Java?

A

A reference type with abstract methods to be implemented by classes.

20
Q

How to implement an interface?

A

Use ‘implements’ keyword in the class definition.

21
Q

What is a package in Java?

A

A namespace that organizes a set of related classes and interfaces.

22
Q

How do you import a package?

A

Use ‘import packageName.ClassName;’ statement.

23
Q

What is exception handling?

A

Managing runtime errors using try-catch-finally blocks.

24
Q

What is the purpose of try-catch?

A

To catch and handle exceptions at runtime.

25
What is the use of 'throw' and 'throws'?
'throw' is used to explicitly throw an exception; 'throws' declares exceptions in method signature.
26
What is the use of 'finally' block?
Executes code regardless of whether an exception is thrown or caught.