Java Fundamentals Flashcards

Learn Java fundamentals required to start programming in Java

1
Q

Difference between JRE and JDK?

A

JRE is a run time environment required to run Java apps. The end-user will install just JRE to run Java apps. JDK is Java development kit. It provides tools to create Java apps. The developer needs JDK to develop Java apps. JDK installation includes JRE for the developer to create and run Java apps.

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

Creating and running Java apps?

A

Source code(*.java) is fed to into JDK which creates Java apps. Java app produced is in byte code format which is an abstraction to run the apps in a platform independent environment. But, that requires a JRE in the host environment to run Java apps.

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

What are packages in Java?

A

Package provide organization of file structure. It follows a set of naming convention.

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

What are the naming conventions for packages?

A

Package names are all lowercase. Package names create uniqueness, so follow a convention in naming a package to create a global uniqueness. These above are just convention nothing like a hard rule.

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

How is Package Name and Source File Structure related?

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

How to execute Java from command line and what are the prerequisites to handle this?

A

Remember to use full class name including package name. On Windows must include JRE bin folder in the PATH environment variable. Finally, run using Java command.

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

What are the primitive data types in Java?

A

Integer Floating point Character Boolean

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

What are different integer types supported in Java along with their sizes?

A

Byte - 1 bytes(8 bits, range: -128 to +127) Short - 2 bytes(16 bits, range: -32768 to 32767) Int - 4 bytes(32 bits, range: -2147483648 to 2147483647) Long - 8 bytes(64 bits, range: -9223372036854775808 to 9223372036854775807) Note: for Long, the literal format would be 0L

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

What are different Floating points supported in Java?

A

Upload image of floating point

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

What are different character types supported in Java?

A

Upload image of character

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

What is the operator precedence in Java?

A

Upload image of operator precedence.

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

How are implicit type conversions done?

A

Upload image

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

How are explicit type conversions done in Java?

A

Upload image

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

How to initialize an array in Java and how to know it’s length?

A

Float[] arr = { 1.1, 2.2, 3.1 }; arr.length —> length of array

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

How is for-each loop used in Java?

A

Upload image

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

Does name of the file in Java matches the name of file?

A

Yes.

The name of the file matches the name of the class.”

“Suppose you decide to create a class that describes a home. You’ll need to create a Home class that will be saved in the file Home.java.”

“If you want to describe a cat in the program, then you’ll have to create a file Cat.java and declare the Cat class in it, etc.”

17
Q

What does the below line of code mean? Explain.

public static void main(String[] args)
A

main method: In Java programming language, every application must contain a main method whose signature is:

public static void main(String[] args)

public: So that JVM can execute the method from anywhere.
static: Main method is to be called without object. 

The modifiers public and static can be written in either order.

void: The main method doesn't return anything.

main(): Name configured in the JVM.

String[]: The main method accepts a single argument: 
          an array of elements of type String.
18
Q
A