Prabhu Sunderaraman

Fullstack Engineer, Programmer, Writer, Trainer

prabhu.bits@gmail.com,     GitHub     Youtube     LinkedIn
  • Home
  • Profile
  • Books
  • Reading List
Browsing: / Home
Shortlink

Quiz on Spring framework – Part II

By Prabhu Sunderaraman on July 19, 2018 in Spring

Take the second quiz on Spring framework and evaluate yourself. If you’ve missed the first one, here you go.

Question #1: What is the convenient callback class that can be used to format results from DB?

RowMapper. Maps each row to the required format

Question #2: What annotation can be used to mark Dao classes?

All the above. Though it makes sense to use @Repository

Question #3: Which annotation is used to provide declarative transactions?

@Transactional. Apply it on a method or a class

Question #4: Checked Exceptions rollback declaratively managed transactions automatically

True. Declarative transactions have to be explicitly configured to rollback when checked exceptions are thrown

Question #5: Which of the following is true for a final class Customer marked for transaction support?

Fails to generate a proxy as it cannot be extended. Final classes cannot be proxied. So you may have to provide interfaces

Question #6: Injecting a session scoped bean in a singleton bean needs a proxy configuration

Yes. A narrow scoped bean cannot be injected directly in a broad-scoped bean. You have to inject a proxy of the narrow scoped bean.

Question #7: What annotation is used to map a method for PUT request?

@PutMapping. Each HTTP verb has an appropriate mapping annotation

Question #8: What annotation is used to map value to the method argument in http://localhost/factorial/{value}?

@PathVariable

Question #9: In Spring Web App, which of the following acts as a Front Controller?

DispatcherServlet. It receives all the requests to the application.

Question #10: What is the property used to change the port to 9090 in a Spring Boot Web application?

server.port=9090. Can be specified in application.properties file or using runtime argument -Dserver.port=9090

Share this on: Mixx Delicious Digg Facebook Twitter
Shortlink

Quiz on Spring framework – Part I

By Prabhu Sunderaraman on July 18, 2018 in Spring

Take this quiz on Spring framework and evaluate yourself

Question #1: What is the annotation equivalent of the setter-based injection in XML?

@Autowired. @Autowired is used to inject beans to a property

Question #2: What’s the default scope of all the beans in a web application?

singleton. There's only one instance of all the beans by default.

Question #3: How do you access a property version=1.0 present in a properties file?

${version}. ${...} is the expression used to access any property

Question #4: What annotation is used to defer the instantiation of beans?

@Lazy. Marking @Lazy on a component defers instantiation of a bean

Question #5: How do you get the reference of a @Component on a class MyAppCode?

getBean("myAppCode"). The convention is the class name with the starting letter in lowercase

Question #6: How do you wire a properties collection to a property?

Using @javax.annotation.Resource

Question #7: What is the central convenient class used for JDBC operations in Spring?

JdbcTemplate. Most of the services are available using some xyzTemplate class in Spring

Question #8: What’s the root unchecked Exception that’s thrown by the Database Template classes?

DataAccessException. This is the root RuntimeException class thrown by the DB Template classes.

Share this on: Mixx Delicious Digg Facebook Twitter
Shortlink

Kotlin Video Series – Functions (Part 1)

By Prabhu Sunderaraman on June 28, 2018 in Kotlin, Languages

This is the seventh part of the video series on Kotlin language.
Read and watch the other parts here.

1. Hello Kotlin
2. Declaring Variables
3. Data Types
4. String (Part 1)
5. String (Part 1)
6. Conditional Expressions

We discuss writing functions in Kotlin language.

We’ve been writing a main function in all these examples. So that should have already given us some idea about the syntax of the functions. A Function is written using the fun keyword.

fun main(args:Array<String>){
   println(sayHello("Sam"))
}
fun sayHello(name:String):String{
    return "Hello $name"
}

You can omit the return type of a function if doesn’t return anything.

  fun print(message:String){
	println(message)
  }

We can also make a function that does not return anything to return Unit, which means Nothing. Unit can be used in Generics, which we will discuss later.

   fun printAgain(message:String):Unit{
	println(message)
}

Functions can be written as expressions, like our if-else and when-else constructs. An add function thats adds two numbers can be written as an expression like this.

  //Normal function 
  fun add(x:Int,y:Int):Int{
	return x + y
   }

   //Expressions
   fun add(x:Int,y:Int) = x + y
   fun square(x:Int) = x * x
}

You can find the video here.

Share this on: Mixx Delicious Digg Facebook Twitter
Shortlink

Kotlin Video Series – Conditional Expressions

By Prabhu Sunderaraman on June 28, 2018 in Kotlin, Languages

This is the sixth part of the video series on Kotlin language.
Read and watch the other parts here.

1. Hello Kotlin
2. Declaring Variables
3. Data Types
4. String (Part 1)
5. String (Part 2)

In this video, we discuss conditional expressions. Yes, it’s conditional expressions and not just conditional statements.

Let’s write a pretty simple if-else condition.

fun main(args:Array<String>){
  val comment:String
  if(age > 50)
      comment = "Getting old"
  else
      comment = "You'll get there"
   println(comment)
 }

if-else conditions can be written as expressions in Kotlin. And that, eliminates the need for having a ternary operator.

   //if-else used as an Expression
   val anotherComment = if(age > 50){
       "Getting Old"
    }
    else{
	"You'll get there"
    }
    println(anotherComment)

    //Even better
    val finalComment = if(age > 50) "Getting Old" else "You'll get there"
    println(finalComment)

The finalComment variable above just resembles our ternary operator. It’s pretty cool.

switch-case statements are available as when statements in Kotlin.

 val age = 52
	
 val comment:String
 when(age) {
    50 -> comment = "Half century"
    25 -> comment = "Young"
    else -> comment = "Hmm"
 }
 println(comment)
	
 val anotherComment:String
 when {
     age > 50 -> anotherComment = "Getting old"
     else -> anotherComment = "You'll get there"
 }
 println(anotherComment)

The when statements can also be written as expressions like this.

   //As an expression
    val finalComment = when {
	age > 50 -> "Getting Old"
	else -> "You'll get there"
    }
    println(finalComment)

You can find the video here.

Share this on: Mixx Delicious Digg Facebook Twitter
Shortlink

Kotlin Video Series – String (Part 2)

By Prabhu Sunderaraman on June 28, 2018 in Kotlin, Languages

This is the fifth part of the video series on Kotlin language.
Read and watch the other parts here.

1. Hello Kotlin
2. Declaring Variables
3. Data Types
4. String (Part 1)

In this video, we discuss string comparison and string templates.

String comparison is a breeze in Kotlin. We can use == to compare two string literals.

fun main(args:Array<String>){
  var lang1 = "java"
  var lang2 = "Java"
  println(lang1 == lang2)
}

Strings can be compared using the .compareTo method too, which gives you an option to compare the values ignoring the case, like this.

  println(lang1.compareTo(lang2,true) == 0)

String templates allow you to embed values in a string using ${expression}

   var comments = "$lang1 is cool"
   println(comments)
   comments = "${lang2} is cool"
   println(comments)

You can find the video here.

Share this on: Mixx Delicious Digg Facebook Twitter
« Previous 1 … 12 13 14 … 64 Next »

Youtube Channel




Categories

  • JavaScript (48)
    • RequireJS (5)
  • Go (44)
  • Golang (44)
  • Ext JS (23)
  • Spring (22)
  • Mobile (21)
  • Scala (20)
    • Play (3)
  • Uncategorized (19)
  • Video Sessions (18)
  • GoG (17)
  • Sencha Touch (16)
  • jQuery (14)
  • Languages (13)
  • Java 8 (12)
  • React JS (11)
  • Kotlin (11)
  • HealthyCodeMagazine (9)
  • Video (9)
  • Objective-C (8)
  • NoSQL (8)
  • Android (7)
  • MongoDB (7)
  • GWT (6)
  • Tools (6)
  • HTML 5 (5)
  • Cloud (5)
  • General (5)
  • Micro services (5)
  • Java (5)
  • Books (4)
  • AWS (4)
  • Software Architecture (4)
  • .NET (3)
  • Elixir (3)
  • Docker (3)
  • Reactive (3)
  • NodeJS (2)
  • RoR (2)
  • Backbone (1)
  • AngularJS (1)

Archives

  • 2020 (49)
  • 2019 (7)
  • 2018 (34)
  • 2017 (15)
  • 2016 (7)
  • 2015 (18)
  • 2014 (31)
  • 2013 (55)
  • 2012 (100)

Search

Subscribe




Copyright © 2025 Prabhu Sunderaraman.

Powered by WordPress and News.