Search This Blog
Wednesday, July 30, 2025
Java Variables - 3

Tuesday, July 29, 2025
Java Data types - 2
Java is a strictly typed language. Unlike C, where the size of some data types is machine-dependent, Java has a fixed size and thus range for every type. Keeping the fact in mind that Java is a strictly typed language, what will be the output of the following code?
1. /**
2. *
3. * @author Nancy
K.A.N.
4. */
5. public class Datatype2Demo {
6. public static void main(String[] args) {
7. short x = 32768;
8. System.out.println("x = "+x);
9. }
10. }
11.
Created by Nancy K.A.N.
@12:50 29-Jul-2025

Monday, July 28, 2025
Java Strings - combining two strings

Sunday, July 27, 2025
Algorithms - 1
Algorithms are essential for every programmer. There are algorithms for searching, sorting, pattern matching, traversing, and more.
Which of the following are sorting algorithms?
a) Binary
b) Boyer-Moore
c) Radix
d) Heap
e) Bubble
Created by Nancy N.
@12:42 27-Jul-2025

Saturday, July 26, 2025
Class Relationships
Aggregation is a special form of _______________________ that represents ownership relationship between two objects.
a) composition
b) inheritance
c) association
d) implementation
Created By Nancy N
@16:40 26-Jul-2025

Friday, July 25, 2025
Java Operators Precedence
Java expressions are created using a combination of variables and operators. When multiple operators are used in the same expression, Java executes these operators in a specific order. This is called operator precedence.
Here are four operators:
a) ++
b) +
c) ()
d) <<
In which order will these be executed if added into the same expression (high to low precedence)?
a) b, c, d, a
b) c, d, a, b
c) c, a, b, d
d) a, b, c, d
Created by Nancy N.
@10:18 25-Jul-2025

Thursday, July 24, 2025
Java DMD
What does DMD in Java stand for?
a) Dispatching Method Dynamically
b) Distributing Messages Dynamically
c) Dynamic Message Distribution
d) Dynamic Method Dispatch
Created by Nancy N.
@12:32 24-Jul-2025

Tuesday, July 22, 2025
Java Datatypes -1
Can you assign a fractional value to an int by typecasting? What will be the outcome of the following code?
1. /**
2. * @author Nancy
K.A.N.
3. */
4. public class Datatype1 {
5. public static void main(String[] args) {
6. int x= (int)4.7;
7. System.out.println("x="+x);
8. }
9. }
10.

Sunday, July 20, 2025
Open-Closed principle
You are writing code for an application following the Open-Closed principle. Which of the following actions will you choose not to violate the Open-Closed principle?
a) You extend an existing class
b) You add a method to an existing class rather than extending it
c) You extend an existing class and also override a method of the superclass
Created by Nancy N.
@11:41 20-07-2025
Follow this blog for more interesting information
Subscribe to the YouTube channel @CodeWithNancy

Friday, July 18, 2025
Value-Based classes Quiz
Which of the following is not a Value-Based class?
a) Integer
b) Double
c) Object
d) Boolean
Created by Nancy N.
@18:04 18-Jul-2025

Monday, July 14, 2025
Java Regular Expressions - Quiz
What will be the output of this regular expression (Java) code?
1. /*
2. * Code by Nancy K.A.N.
3. */
4. import java.util.regex.Matcher;
5. import java.util.regex.Pattern;
6.
7. public class RegexSubStringTest {
8. public static void main(String[] args) {
9. String str1 = "This is an example of 'Java Regular
Exressions'";
10. Pattern pattern = Pattern.compile("'(.*?)'");
11. Matcher matcher = pattern.matcher(str1);
12. if (matcher.find())
13. {
14. System.out.println(matcher.group(1));
15. }
16. }
17. }
18.
Created by Nancy K.A.N.
@17:13 14-Jul-2025
Follow my YouTube channel: @CodeWithNancy

Sunday, July 13, 2025
Bitwise Shift Operators - 1
What is the output of the following code?
/**
* @author Nancy K.A.N.
*/
public class BitwiseDemo1 {
public static void main(String[] args) {
int a =4;
int b = a<<3;
System.out.println(b);
}
}
By Nancy K.A.N.
@22:06 13-Jul-2025
Follow my YouTube channel @CodingWithNancy

Friday, July 11, 2025
Product Life Cycle Stages
The software industry accepts and follows the following life cycle stages for a product:
1. Project proposal
2. Requirement gathering and analysis
3. Designing
4. Code development
5. Testing
6. Implementation
7. Maintenance
8. End Of Life (EOL)
8-A An entirely new product or another product with better features
Created by Nancy K.A.N.
@15;42 11-Jul-2025

Thursday, July 10, 2025
Some Acronyms - Programming practices
DRY - Don't Repeat Yourself
KISS - Keep It Simple Stupid
SLAP - Single Level Abstraction Principle
SOLID - contains five principles (SRP, OCP, LSP, ISP, DIP)
SRP - Single Responsibility Principle
OCP - Open-Closed Principle
LSP - Liskov Substitution Principle
ISP - Interface Segregation Principle
DIP - Dependency Inversion Principle
Created by Nancy K.A.N.
@21:17 10-Jul-2025

Wednesday, July 9, 2025
Java Best Practices
In Java, what are the best practices for naming classes and variables?
a) Upper Camel case for class names
b) Lower camel case for class names
c) Upper Camel case for variable names
d) Lower Camel case for variable names
e) all lowercase for class names as well as variable names
Created by Nancy K.A.N.
@19:10 09-Jul-2025

Tuesday, July 8, 2025
Java Platform - 1
Java incorporated platform independence by ___________________.
a) Interfaces
b) classes
c) Java Native Interface
d) Java Virtual Machine
Created by Nancy K.A.N.
@13:39 08-Jul-2025

Monday, July 7, 2025
Java Interfaces Default Methods
In which Java version were the interface default methods introduced?
a) Java 7
b) Java 8
c) Java 9
d) Java 11
Created by Nancy K.A.N.
@17:32 07-Jul-2025

Sunday, July 6, 2025
Java Value-Based class
A Value-Based class is a Java class that wraps a value. All the wrapper classes (Byte, Short, Integer, Long, Character, Float, Double, and Boolean) in Java are Value-Based classes, as they wrap the primitive type. In addition to the wrapper classes, the Optional class and the Date and Time API classes are also Value-Based classes.
A Value-Based class contains final fields and does not contain accessible constructors.
Which of the following statements is NOT true about Value-Based classes?
a) The class uses the instance's monitor to perform synchronization
b) If accessible constructors are created, they should be marked deprecated
c) The class should be instantiated only by using a factory method
d) The Value-Based class is always final
Created by Nancy K.A.N.
@22:22 06-Jul-2025
Follow on YouTube Coding With Nancy

Saturday, July 5, 2025
Java String API - 2
What is the output of the following code?
(Hint: CharSequence is an interface.)
Created by Nancy K.A.N.
@12:10 05-Jul-2025
Follow on YouTube Coding With Nancy

Friday, July 4, 2025
Java Behavioral Design Patterns
Behavioral patterns in Java address object communication. Using behavioral patterns, you can define the interaction and communication among objects as well as between objects and the user. For example, you can use behavioral design patterns to distribute responsibilities or a chain of command. Which of the following are behavioral patterns?
a) Command pattern
b) Observer pattern
c) Singleton pattern
d) Factory pattern
e) Facade pattern
Created by Nancy K.A.N.
@14:14 04-Jul-2025

Wednesday, July 2, 2025
Java Variables - 2
Which of the following are invalid variable names in Java?
a) !
b) $
c) _$
d) _
Created by Nancy K.A.N.
@23:09 02-Jul-2025

Tuesday, July 1, 2025
Java String API - 1
Which of the following methods is used to convert a Java String to an array of characters?
a) split()
b) getChars()
c) getBytes()
d) toCharArray()
Created by Nancy K.A.N.
@23:05 01-Jul-2025
