Drools Interview Questions and Answers

Drools Interview Questions and Answers

Last updated on 05th Oct 2020, Blog, Interview Question

About author

Rakshan ((Sr Technical Director )

He is a Expertise in Following Technical Domain with 7+ Years of Experience Also, His Informative Technical Writing Blogs Helps Freshers & JOB Seeker to Enhance their Career

(5.0) | 15411 Ratings 1877

If you’re looking for Drools Interview Questions for Experienced or Freshers, you are at right place. There are lot of opportunities from many reputed companies in the world. According to research Drools has a market share of about 1.7%. So, You still have opportunity to move ahead in your career in Drools Development. Mindmajix offers Advanced Drools Interview Questions 2019 that helps you in cracking your interview & acquire dream career as Drools Developer.

1.What is Drool?

Ans:

Drools is the Business Rule Management System (BRMS) provided by the JBoss Community for implementing complex applications with automatic behaviors based on rules. The framework is essentially based on an extension of the Rete pattern-matching algorithm.

2.What are the features of JBoss Enterprise Web Platform?

Ans:

The JBoss Enterprise Web Platform is the software infrastructure that supports the running of BRMS components.

3.What is MVEL Dialect?

Ans:

MVEL is an expression language for Java-based applications. It supports field and method/getter access. It is based on Java syntax.

4.Why use Drools and not other programming languages?

Ans:

The rules logic can be done in a programming language like Java .Consider a Jewellery shop which needs to maintain business logic of calculating discount based on the type of Jewellery. But such rules may change daily and need to be updated regularly in our code which is not good. Also we will always require a Developer for making such changes. So its a good practice to define this logic as rules in a Business Rule Management System. If tomorrow the discount is to be changed this can be done even by a non technical person.

5.JBoss Enterprise BRMS?

Ans:

JBoss Enterprise BRMS is a business rule management system and reasoning engine for business policy and rules development, access, and change management. JBoss Enterprise BRMS is a productized version of Drools with enterprise-level support available. JBoss Rules is also a productized version of Drools, but JBoss Enterprise BRMS is the flagship product.

Components of the enterprise version:

    1. 1. JBoss Enterprise Web Platform – the software infrastructure, supported to run the BRMS components only
    2. 2. JBoss Enterprise Application Platform or JBoss Enterprise SOA Platform – the software infrastructure, supported to run the BRMS components only

Subscribe to our youtube channel to get new updates..!

Business Rules Engine – Drools Expert using the Rete algorithm and the Drools Rule Language (DRL)

    1. 3.Business Rules Manager – Drools Guvnor – Guvnor is a centralised repository for Drools Knowledge Bases, with rich web based GUIs, editors, and tools to aid in the management of large numbers of rules.
    2. 4.Business Rules Repository – Drools Guvnor

Drools and Guvnor are JBoss Community open source projects. As they are mature, they are brought into the enterprise-ready product JBoss Enterprise BRMS.

Components of the JBoss Community version:

    1. 1. Drools Guvnor (Business Rules Manager) – a centralized repository for Drools Knowledge Bases
    2. 2. Drools Expert (rule engine) – uses the rules to perform reasoning
    3. 3. Drools Flow (process/workflow), or jBPM 5 – provides for workflow and business processes
    4. 4. Drools Fusion (event processing/temporal reasoning) – provides for complex event processing
    5. 5. Drools Planner/OptaPlanner (automated planning) – optimizes automated planning, including NP-hard planning problems

Example

This example illustrates a simple rule to print out information about a holiday in July. It checks a condition on an instance of the Holiday class, and executes Java code if that condition is true.

  • rule “validate holiday”dialect “
  • dialect”mvel”
  • dialect “java”
  • when
  • $h1 : Holiday( month == “july” )
  • then    
  • System.out.println($h1.name + “:” + $h1.month);
  • end

The purpose of dialect “mvel” is to point the Getter and Setters of the variables of your Plain Old Java Object (POJO) classes. Consider the above example, in which a Holiday class is used and inside the circular brackets (parentheses) “month” is used. So with the help dialect “mvel” the getter and setters of the variable “month” can be accessed.

Dialect “java” is used to help us write our Java code in our rules. There is one restriction or characteristic on this. We cannot use Java code inside “when” part of the rule but we can use Java code in “then” part.

We can also declare a Reference variable $h1 without the $ symbol. There is no restriction on this. The main purpose of putting the $ symbol before the variable is to mark the difference between variables of POJO classes and Rules.

User cannot use Java code inside “when” part of the rules. However, it can be use in the “then” part.

6.What is a Rule?

Ans:

Rules are pieces of knowledge often expressed as, “When some conditions occur, then do some tasks.”

  • When
  • Then  

The most important part of a Rule is its when part. If the when part is satisfied, the then part is triggered.

  • rule
  • when
  • then
  • end

7.What are Drool Workbench, Expert, and Fusion?

Ans:

Drools Workbench is the web user interface for authoring and management. Drools Expert is the business rule engine and Drools Fusion is the complex event processing feature.

8.What is meant by accumulate in DRL Drools?

Ans:

Accumulate is conditional element that was introduced in Drools version 4.0. It is used to iterate over the list of objects and help validation of data in Java operation.

Ex.

  • accumulate (Counter() ; $cnt : count())

9. What is meant by KIE?

Ans:

KIE stands for Knowledge is everything. It stands for Knowledge is everything. From Drools 6.0 onwards a new approach is used to create a Knowledge Base and a Knowledge Session. Knowledge base is an interface that manages a set of rules and processes. The main task of the knowledge base is to store and re-use rules because creation of rules is very expensive.Rules are contained inside the package org.drools.KnowledgeBase. These are commonly referred to as knowledge definitions or knowledge. Knowledge base provides methods for creating a Session.

10.What is the productized version of Drools?

Ans:

JBoss Enterprise BRMS is the productized version of Drools and it has enterprise level support.

Subscribe For Free Demo

Error: Contact form not found.

11.What is Knowledge Session?

Ans:

The knowledge session is retrieved from the knowledge base. It is the main interface for interacting with the Drools Engine. The knowledge session can be of two types:

    1. 1.Stateless Knowledge Session
    2. 2.Stateful Knowledge Session

12.How to remove object from knowledge session?

Ans:

Using retract method to remove the object from knowledge session can help.

13.What is the global variable in Drools?

Ans:

The global variable in Drools is the keyword. Global is the variable used in Drool and is visible in all rules inside the DRL file.

14.What is the other nomenclature for Drool?

Ans:

Drool is also called a production rule system that uses an enhanced implementation of the Rete algorithm. 

15.What is the standard supported by drool?

Ans:

Drool supports enterprise framework for enforcement, construction and maintenance for business policies along with JSR-94 standards for the business rule engine. 

16.What are the components of jBoss Enterprise version?

Ans:

jBoss enterprise version has the following components – JBoss Enterprise application of SOA platform, Business Rules Engine,   JBoss Enterprise web platform, and Business Rules Manager.

17.What are the features of JBoss Enterprise Application Platform?

Ans:

Some important features of JBoss Enterprise Application Platform are as follows –  

  • Eclipse-based IDE is available using JBoss developer studio
  • java persistence using hibernate 
  • Supports Java EE and web services standards
  • Object request broker using JacORB for interoperability with CORBA objects. 

18.What is Drool flow?

Ans:

Drool flow provides workflow capabilities to the drool platform. Workflow describes the order of steps that need to be executed. Drool flow allows users to execute and monitor their business logic.

19.What are the decision tables?

Ans:

In drools, decision tables are the excel-based tables. The logic in these tables can be understood and changed by the non-technical person. As the .drl file is difficult to manage, therefore, decision table is a good option which can be easily managed by non-programmers.

20.What do you understand by Drools stateful Vs Stateless knowledge session?

Ans:

Stateless Session

Any changes in the facts while executing rules is not made aware to the rule engine.

dispose() method is called automatically to release the session.

Any changes in the facts while executing rules is not made aware to the rule engine so if any rule is modified no other re-activation of rules will take place. 

Stateful Session

Any changes in the facts while executing rules is made aware of the rule engine.

dispose() method should be called to release the session to avoid memory leaks.

As any changes in facts is available to the rule engine so if a rule is modified for a particular fact, this change will re-activate all the rules and fire the rules that are built on modified fact.

21.How do we implement backward chaining in Drools?

Ans:

In background chaining, the first user takes a decision and then checks whether the decision is true or not by tracking the sequence of events. It is also referred to as derivation queries and drools implements that through query construct.

22.Which Drools attribute have you used?

Ans:

There are following attributes used in Drools –

  • Salience – Drools used salience in order to figure out which drool to fire first 
  • No-loop  – Indefinite looping is avoided by using no-loop attribute 
  • Update statement – The update statements let the rules engine if any fact is modified. 

23.List out different execution control statements used in drools?

Ans:

  • agenda-group – This is an optional keyword. If rule is not assigned to any agenda group, by default it belongs to the main agenda.
  • activation-group – It is a reserved keyword in drl file. Both single rule or multiple rules can belong to a particular activation-group.
  • ruleflow-group – It behaves very similar to agenda-group, it is primarily used for rules used in jBPM process flows.

24.Have you ever integrated Drools with other frameworks?

Ans:

Yes, I have used Drools with Spring Framework.

25.How is Drool different from other programming languages?

Ans:

Unlike other programming languages, Drool offers several modifications to be applied on coding and do not work on a certain set of patterns. Conventional programming languages do not provide any management solution for businesses which is the main feature of Drool.

26.What are the benefits of using rule engines in business project management?

Ans:

Following are the advantages of using rule engines in a business project management –

  • High flexibility – Knowledgebase lets you adjust effectively about your choices when they are evolving.
  • Easy to learn – Rules are very easy to understand as compared to procedural code. 
  • Reduced intricacy – Rules handle expanding multifaceted nature as they utilize predictable business rules
  • Reusability – Business rules can be reused 
Course Curriculum

Get Hands-On Practical Drools Training to Advance Your Career

  • Instructor-led Sessions
  • Real-life Case Studies
  • Assignments
Explore Curriculum

27.What do you understand about Drools process?

Ans:

Drool process is a framework that provides a flow of work along with various business processes.

28.Why do we use the symbol “$” before every variable?

Ans:

In Drools, we use “$” before every variable to ensure that there is no difference between POJO class and variables of rules.

29.What is Drool planner?

Ans:

Drool planner is also called automated planning that optimizes the process during NP-hard planning issues.

30.What does JBPM do?

Ans:

JBPM is a light-weight workflow engine written in Java and allows you to execute business processes with the latest BPMN 2.0 specification. It runs on any Java environment you have as an application or service.

31.What is global in a DRL file?

Ans:

Global is a keyword used while defining any variable which would be visible to all the rules in a DRL file. A global variable can be used with any type of object. Global must be used very carefully with the DRL file because any changes in the global variable are not notified to the working memory. 

32.Differentiate between StringBuffer class and StringBuilder class?

Ans:

StringBufferStringBuilder
StringBuffer is synchronized ie. two threads can’t call the method at the same timeStringBuilder is unsynchronized ie. two threads can call the method at the same time
Less efficient as compared to StringBuilderBetter than StringBuffer

33.Which tool is used to manage complex event processing in Drools?

Ans:

Drool fusion is used for event processing and temporal reasoning. 

34.What is the use of dialect in Drools?

Ans:

Dialect is used to write Java code in the rules and  points to the Getter and Setters of the variables of POJO (plain old Java objects) 

35.Can we use round trips between rules modified in Guvnor, load in the UI, modify and upload to Guvnor?

Ans:

There is no such way to ensure this. Newcomers should not at all try this to avoid complications.

36.Can we work with a custom UI instead of using the Guvnor Rule?

Ans:

It is possible to store the rules in the custom domain model in the database and generate the DRL from the same model. This helps render the Guvnor redundant in the custom environment.

37.What is the restriction in Java code?

Ans:

A user cannot use Java code inside “when” part of the rules. However, it can be used in the “then” part.

38.Explain Drool Workbench, Expert, and Fusion?

Ans:

Drools Workbench is the web user interface for authoring and management. Drools Expert is the business rule engine and Drools Fusion is the complex event processing feature.

39.How to halt the process in a DRL file?

Ans:

User has to resort to drools.halt() in the consequence (then) part of the application.

40.How to remove the object from the knowledge session?

Ans:

By using the retract method, we can remove the object from the knowledge session.

41.How to fetch and play around with the rules in java code?

Ans:

Rules does not exist as the Java codes. However it is possible using Guvnor REST API for downloading the DRL source code for the rules and thereafter uploads them all over again.

42.Is it possible using round trips between rules modified in Guvnor, loade in the UI, modified and uploaded to Guvnor?

Ans:

There is no such way of ensuring this. Especially newcomers should not try this to avoid complications.

43.Is it possible working with completely custom UI instead of using Guvnor Rule?

Ans:

Rules can be stored in the custom domain model in a database generating the DRL from that model. This can render Guvnor redundant in the custom environment.

44.What is meant by Drools Recursive Rules?

Ans:

A Fibonacci series is the most common example of recursion in Drools. In the Drools the implementation is carried out using the insert and modifies keywords.

45.What are the most important parts of Recursion in Drools?

Ans:

The three most important parts of in the process of implementation of recursive rules in Drools are inserting keywords in ‘then’ part, not keyword used in ‘when’ part, and ‘breaking condition’.

drools Sample Resumes! Download & Edit, Get Noticed by Top Employers! Download

46.What would be the breaking condition in Fibonacci series?

Ans:

The breaking condition in Fibonacci series would be (sequence==1).

47.Features of Drool?

Ans:

Here are important features of Drool:

  • Helps you to separate application from dynamic logic
  • Declarative Programming
  • Centralization of Knowledge
  • Speed and Scalability
  • Separate logic from application

48.Disadvantages of Rules Engine

Ans:

Here, are drawbacks/ cons of using rules engine:

  • Lots of learning effort requires by developers to know this method of programming
  • Rule engine is not a secure method to troubleshoot issues.
  • Needs to understand the working of rule engine to consumes more memory
  • There are a wide set of rules for a complex branching.

Rules may change over time and will become effective with code changes

  • Understandable rules

49.What are the The rules?

Ans:

Ok, now that we know which data do we have, we can express rules based on that model.

Let’s see some examples of rules we may want to write:

  • We may have sequences of emails, for example the content of a course. They have to be sent in order
  • We may have time sensitive emails that should either be sent in a specific time window or not sent at all
  • We may want to avoid sending emails on specific days of the week, for example on the public holidays in the country where the subscriber is based
  • We may want to send certain type of emails (for example proposing a deal) only to persons who received certain other emails (for example at least 3 informative emails on the same subject)
  • We do not want to propose a deal on a certain product to a subscriber who has already bought that product
  • We may want to limit the frequency we send emails to users. For example, we may decide to not send an email to a user if we have sent already one in the last 5 days

50.Who use the Business Rules Engine?

Ans.

Drools experts use the Business Rules Engine through Rete algorithm and Drools Rule Language (DLR).

51.Drools Characteristics ?

Ans:

CriteriaResult
FunctionalityBusiness rules management & reasoning engine
ScopeCan be used for local decisions or large scale decisions

52.If there are still rules that need to be managed in Guvnor what steps user should take?

Ans:

If the user still has rules that are required to manage in Guvnor then he or she should generate the DRL and upload it into Guvnor using REST API.

53.Where global variable should be used?

Ans:

Where in the rules requirements for database connection object is necessary, global variable should be used. For instance; The DB connection object could be global variable.

Are you looking training with Right Jobs?

Contact Us

Popular Courses